FROM : John Stiles
DATE : Mon Dec 13 19:41:02 2004
I think if you want the best performance for writing huge solid blocks
of data, try open/pread/pwrite.
If you're doing scattershot small accesses throughout the file, try
mmap.
fopen/fread/fwrite are okay, but they are really meant for tiny
accesses; I believe they break up all data accesses into 4K chunks,
even if you ask for huge blocks. As a result, you will find that the
kernel consumes a little more CPU time when you use fread/fwrite versus
read/write. I used to think the difference was irrelevant, but then I
timed it both ways and open/pread/pwrite was measurably superior.
On Dec 13, 2004, at 10:27 AM, Juan Pablo Pertierra wrote:
> Hello,
> My program writes(and reads) very large files from the hard drive. Do
> the standard functions fwrite/fread provide the maximum level of
> performance for doing these operations within a Cocoa application, or
> do I need to use some other lower-level method? Should I use
> NSFileHandle instead of fwrite/fread/etc functions? It is very
> important that I get the maximum possible performance in writing the
> files, i don't really care if the computer does nothing else when
> writing.
>
> Thanks in advance,
> Juan
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Cocoa-dev mailing list (<email_removed>)
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/<email_removed>
>
> This email sent to <email_removed>
DATE : Mon Dec 13 19:41:02 2004
I think if you want the best performance for writing huge solid blocks
of data, try open/pread/pwrite.
If you're doing scattershot small accesses throughout the file, try
mmap.
fopen/fread/fwrite are okay, but they are really meant for tiny
accesses; I believe they break up all data accesses into 4K chunks,
even if you ask for huge blocks. As a result, you will find that the
kernel consumes a little more CPU time when you use fread/fwrite versus
read/write. I used to think the difference was irrelevant, but then I
timed it both ways and open/pread/pwrite was measurably superior.
On Dec 13, 2004, at 10:27 AM, Juan Pablo Pertierra wrote:
> Hello,
> My program writes(and reads) very large files from the hard drive. Do
> the standard functions fwrite/fread provide the maximum level of
> performance for doing these operations within a Cocoa application, or
> do I need to use some other lower-level method? Should I use
> NSFileHandle instead of fwrite/fread/etc functions? It is very
> important that I get the maximum possible performance in writing the
> files, i don't really care if the computer does nothing else when
> writing.
>
> Thanks in advance,
> Juan
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Cocoa-dev mailing list (<email_removed>)
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/<email_removed>
>
> This email sent to <email_removed>
| Related mails | Author | Date |
|---|---|---|
| Juan Pablo Pertier… | Dec 13, 19:27 | |
| John Stiles | Dec 13, 19:41 | |
| Erik M. Buck | Dec 14, 00:58 |






Cocoa mail archive

