Re: Optimal read buffer size?
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