• 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: Optimal read buffer size?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Optimal read buffer size?


  • Subject: Re: Optimal read buffer size?
  • From: Quinn <email@hidden>
  • Date: Fri, 20 May 2005 11:42:53 +0100

At 13:14 -0700 18/5/05, Peter Bierman wrote:
The best way to do that on OS X is to memory map your destination file and pass that address to the read() calls so that the kernel is copying the data directly from the network buffers to the address space that you've told the VM system to connect to your file.

Just FYI, if you're reading a large file from the network, the best approach is:


o allocate a set of page-aligned, multiple-of-a-page-size, buffers in user space

o read into those buffers using the standard sockets API

o when a buffer fills up, write it to disk asynchronously using non-caching I/O

For streaming large chunks of data, non-caching I/O gives better performance than memory memory mapped I/O. They both spend the same amount of time copying data (the kernel's copy from the mbuf to your data buffer), but non-caching I/O has less CPU overhead on the write and puts less memory pressure on the system.

S+E
--
Quinn "The Eskimo!"                    <http://www.apple.com/developer/>
Apple Developer Technical Support * Networking, Communications, Hardware
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Optimal read buffer size?
      • From: Scott Ribe <email@hidden>
References: 
 >Optimal read buffer size? (From: Chaz McGarvey <email@hidden>)
 >Re: Optimal read buffer size? (From: Justin Walker <email@hidden>)
 >Re: Optimal read buffer size? (From: Chaz McGarvey <email@hidden>)
 >Re: Optimal read buffer size? (From: Peter Bierman <email@hidden>)

  • Prev by Date: Fwd: Optimal read buffer size?
  • Next by Date: Re: How can I a String to IP ?
  • Previous by thread: Re: Optimal read buffer size?
  • Next by thread: Re: Optimal read buffer size?
  • Index(es):
    • Date
    • Thread