On Tue, May 15, 2012 at 11:15:29PM +0200, Alfredo Finelli wrote: > Mark Hindley: > > Thanks. > > > > From a purely selfish apt-cacher point of view we don't call select() > > directly, it is only through IO::Select. Although I am reluctant to > > deflect the blame, I think this maybe a perl-base bug. > > > > Could you try this script and play with the timeout value in > > $select->can_read(). Obviously it should print an elapsed time for each > > loop of the order of the can_read timeout. I get something of the > > correct order right down to 1us (perl 5.10.1). What do you get? > > Here my results.
OK, I accept that this is not working properly on faster systems (than I have). Actually the impact on response time and throughput is not as great as I had previously thought either. This is my proposed solution -- I would be grateful if you could test that it fixes it for you. I have implemented a new configuration option curl_throttle with a default of 1 (equivalent to 1ms). You could persuade me the default should be 10ms :) Mark commit d5b2f01b423954e823306ee587ee95b0dd867ef5 Author: Mark Hindley <m...@hindley.org.uk> Date: Wed May 16 14:09:29 2012 +0100 Implement curl_throttle to control libcurl CPU usage. Value is number of milliseconds IO::Select->can_read() will wait for a new connection before timing out and continuing to fetch. diff --git a/apt-cacher b/apt-cacher index 775b008..c90d9f0 100755 --- a/apt-cacher +++ b/apt-cacher @@ -1482,7 +1482,7 @@ sub connect_curlm { # timeout here which also prevents the parent while # loop from running too fast and hogging the CPU # uselessly. - if ($active_handles && $select->can_read(0.00001)) { + if ($active_handles && $select->can_read($cfg->{curl_throttle}/1000)) { $cfg->{debug} && debug_message('Pending connection'); next LIBCURL_REQUEST; } diff --git a/debian/apt-cacher.8 b/debian/apt-cacher.8 index 26c140c..fa0ed44 100644 --- a/debian/apt-cacher.8 +++ b/debian/apt-cacher.8 @@ -415,6 +415,12 @@ closing the connection. The maximum time in seconds the libcurl backend will wait, unused, before exiting. .TP +.B curl_throttle [1] +Controls how fast the libcurl process runs. Increasing this setting will reduce +the CPU load of the libcurl process, possibly at the expense of slower response +times and a lower throughput. On most systems this option should be left +unchanged. +.TP .B request_empty_lines [5] The number of empty lines tolerated before an incoming connection is closed. .TP diff --git a/lib/apt-cacher.pl b/lib/apt-cacher.pl index 1a460ea..f1ec427 100755 --- a/lib/apt-cacher.pl +++ b/lib/apt-cacher.pl @@ -38,6 +38,7 @@ sub read_config { } $count}, curl_idle_timeout => 120, + curl_throttle => 1, daemon_port => 3142, debug => 0, denied_hosts => '', -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org