Re: [Q] is NSFileHandle's writeData method faster than the FSWriteFork?
Re: [Q] is NSFileHandle's writeData method faster than the FSWriteFork?
- Subject: Re: [Q] is NSFileHandle's writeData method faster than the FSWriteFork?
- From: James Bucanek <email@hidden>
- Date: Mon, 4 Aug 2008 10:05:47 -0700
That probably won't gain you that much. Fractional page writes
will still requires FSWRriteFork to first copy the data into its
file buffer, which is where I suspect much of your current
overhead is.
Writing your data into a local, aligned, buffer shouldn't be too
difficult to re-engineer. I assume that it's your code that's
performing the FSWriteFork calls. Replace that with a subroutine
to copy the fractional block into your own buffer. When you have
some multiple of getpagesize() bytes copied, write that and repeat.
The solution for my application was only a little more
sophisticated. My code maintains a set of circular buffers and
the data is written to the file on a separate thread. My main
thread can continue to assemble new data while the first
buffer's worth is being written concurrently.
Also consider asking this question on the filesystem-dev list.
There's some serious filesystem knowledge on that list that
often doesn't have time to monitor Cocoa-dev.
James
JongAm Park <mailto:email@hidden> wrote
(Sunday, August 3, 2008 8:55 PM -0700):
Thank you very much for the valuable information.
I will try the 1st and the 3rd options, because the 2nd option will not be easily applicable withouth refactoring the current code a lot.
- Align the data to be written in memory to page boundaries
(man valloc).
- Write data in multiples of page size blocks (man getpagesize)
- Turn off caching (see Cache Constants of FSWriteFork)
--
James Bucanek
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden