Results 1 to 3 of 3

Thread: High performance large file reading on OSX

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    Join Date
    Apr 2009
    Posts
    9
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: High performance large file reading on OSX

    Hi caduel,

    thanks for your suggestions -- memory mapping the file would be an option that could circumvent the problem. However we have a large existing codebase that is based on QDataStream, QFile and so on for loading those large files which we would like to continue to use.

    The function call
    Qt Code:
    1. fcntl(file.handle(), F_NOCACHE, 1);
    To copy to clipboard, switch view to plain text mode 
    successfully disables caching but why does read performance suffer that much -- is Qt doing something else behind the scenes?

    When using standard C calls for reading a large file, caching can be disabled while retaining the original high read performance:

    Qt Code:
    1. int fd = open(src.toStdString().c_str(), O_RDONLY);
    2. fcntl(fd, F_GLOBAL_NOCACHE, 1);
    3. size_t bufferSize = 1024ul*1024ul*2000ul;
    4. char* buffer = new char[bufferSize];
    5. read(fd, buffer, bufferSize);
    6. close(fd);
    7. delete[] buffer;
    To copy to clipboard, switch view to plain text mode 

    Any ideas why disabling caching slows down Qt but not the original C calls?
    Last edited by mikeee7; 15th October 2009 at 14:44. Reason: spelling error

Similar Threads

  1. Reading and rereading a file with QXmlStreamReader
    By TheRonin in forum Qt Programming
    Replies: 14
    Last Post: 30th April 2015, 14:04
  2. reading bytes out of a file
    By priceey in forum Qt Programming
    Replies: 7
    Last Post: 6th October 2009, 16:55
  3. Character by Character (Unicode?) File Reading
    By mclark in forum Qt Programming
    Replies: 4
    Last Post: 22nd April 2009, 15:28
  4. help in reading XML file
    By cshiva_in in forum Qt Programming
    Replies: 1
    Last Post: 24th March 2008, 13:55
  5. QTextStream loses position while reading file
    By bjh in forum Qt Programming
    Replies: 2
    Last Post: 13th February 2008, 15:47

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.