• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: [Q] is NSFileHandle's writeData method faster than the FSWriteFork?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Q] is NSFileHandle's writeData method faster than the FSWriteFork?


  • Subject: Re: [Q] is NSFileHandle's writeData method faster than the FSWriteFork?
  • From: JongAm Park <email@hidden>
  • Date: Thu, 07 Aug 2008 11:12:44 -0700

Hello.

I implemented it to reduce # of disk I/O and used valloc and realloc. Because it should accumulate data between each callback from the FCP, I tried realloc them. And the result was... it is much faster than the original code. I even remove intermediate codes for threading!

Thank you very much for the information!

Best regards,
JongAm Park

James Bucanek wrote:
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)

_______________________________________________

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


References: 
 >Re: [Q] is NSFileHandle's writeData method faster than the FSWriteFork? (From: James Bucanek <email@hidden>)

  • Prev by Date: Saving Outline View Column Widths
  • Next by Date: How do I get those 1 pixel black lines into my app window?
  • Previous by thread: Re: [Q] is NSFileHandle's writeData method faster than the FSWriteFork?
  • Next by thread: Core Data saved doc compatibility issues ...
  • Index(es):
    • Date
    • Thread