curl-library
Re: [PROF RFC 1/2] profiling of libcurl by curl-loader, steady state
Date: Tue, 17 Apr 2007 23:54:00 +0100
Daniel Stenberg wrote:
> Possibly we should simply detect that no millisecond timeout option is
> used, and then switch to a more "sloppy" approach. That could perhaps
> involve getting the time immediately when curl_multi_socket*() is called
> and then simply not get it again (i.e keep returning the same) unless one
> of the functions is called that we know is time consuming.
As far as I know, the only way to remove lots gettimeofday() or
equivalent calls, from code like this which must detect timeouts
rapidly, is to use some kind of signal (SIGALRM etc.) to set a flag,
or a thread which sleeps for the appropriate time, then wakes and sets
a flag, or other equivalent things (like POSIX timer events).
It's a noticable performance improvement in event-driven code with an
unpredictable mixture of short and long processing in each event.
(That's why a counting method doesn't work, as you note).
Unfortunately, they're all difficult to use in a library which is used
in lots of different kinds of program, and mustn't use process-global
resources.
But those techniques might work fine with the HiPer enhancements, as
that kind of time optimisation can be part of the application, just as
the select() call is, and integrate with the application's use of
signals and threads.
-- Jamie
Received on 2007-04-18