Socket read tuning on Mac OS X
Socket read tuning on Mac OS X
- Subject: Socket read tuning on Mac OS X
- From: Jakub Bednar <email@hidden>
- Date: Fri, 2 Apr 2010 16:18:51 +0200
Hello list,
I have written an application, that communicates using HTTP protocol. During testing, I found out, that with high download speed the CPU usage of my application is pretty high on some systems.
Performance testing with Shark showed, that the problem is in a socket read() operation. I'm using the poll()/read()/write() mechanism specified by POSIX.
On the systems were the CPU usage is normal, the read() system call regularly returns about 10kB of data per read. These systems have a default Ethernet driver (e.g. my Mac Book Pro with nvenet.kext driver)
On the systems with high CPU usage, the read() system call regularly returns only about 1.4kB of data per read, leading to 10x bigger overhead ===> higher CPU usage. An example of this system
is an iMac with AppleYukon2.kext driver or a Mac Book Air with Ethernet over USB.
I have checked all the sysctl options and there is no difference. It seems to me, that this is a driver issue. If I put a small sleep before every read, more data are returned per read(), leading
to rapid drop of CPU usage at a cost of slight drop of download speed. So I wonder, is there a way how to reconfigure a socket to tell him something like: "Give me about xxx kB of data per read, but if
that amount is not available in a specified time, give me what you have."?
I have tried SO_RCVLOWAT along with SO_RCVTIMEO options, but this is not the way. Poll() does not respect SO_RCVLOWAT and the socket will not give me less data but return an error when
SO_RCVTIMEO timeout expires.
Please, any ideas how to solve this?
Thanks a lot,
Jakub _______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden