[Libvir] Patch to make reading of HTTP response more efficient

When processing the header of HTTP responses from Xend, libvirt currently reads data a single byte at a time. Since its using lowlevel UNIX read() function there is no buffering, which results in a large number of system calls. The attached patch re-factors the code so that it reads data in 4k chunks whenever possible. Since most rsponses are < 4k in size processing the response now only takes two read() syscalls, rather than several hundred. Of course most (90%) of the CPU overhead is still on the Xend/XenStored end of the channel, but that's out of our control until the XML-RPC API comes along. Regards, Dan. -- |=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=| |=- Perl modules: http://search.cpan.org/~danberr/ -=| |=- Projects: http://freshmeat.net/~danielpb/ -=| |=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|

On Thu, Mar 30, 2006 at 03:51:06PM +0100, Daniel P. Berrange wrote:
When processing the header of HTTP responses from Xend, libvirt currently reads data a single byte at a time. Since its using lowlevel UNIX read() function there is no buffering, which results in a large number of system calls. The attached patch re-factors the code so that it reads data in 4k chunks whenever possible. Since most rsponses are < 4k in size processing the response now only takes two read() syscalls, rather than several hundred.
Right, good optimization ! Applied, I just reindented and cleaned a bit, it's commited in CVS, thanks a lot !
Of course most (90%) of the CPU overhead is still on the Xend/XenStored end of the channel, but that's out of our control until the XML-RPC API comes along.
There is a awful lot of things that can be done to optimize, like keeping the connection alive, trying to do minimal caching,that we really didn't try to address yet. At this point this is more about functionalities than getting optimal, but this will come :-) Daniel -- Daniel Veillard | Red Hat http://redhat.com/ veillard@redhat.com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
participants (2)
-
Daniel P. Berrange
-
Daniel Veillard