ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libev/ev.3
(Generate patch)

Comparing libev/ev.3 (file contents):
Revision 1.39 by root, Fri Dec 7 19:15:39 2007 UTC vs.
Revision 1.40 by root, Fri Dec 7 19:23:48 2007 UTC

2404.SH "COMPLEXITIES" 2404.SH "COMPLEXITIES"
2405.IX Header "COMPLEXITIES" 2405.IX Header "COMPLEXITIES"
2406In this section the complexities of (many of) the algorithms used inside 2406In this section the complexities of (many of) the algorithms used inside
2407libev will be explained. For complexity discussions about backends see the 2407libev will be explained. For complexity discussions about backends see the
2408documentation for \f(CW\*(C`ev_default_init\*(C'\fR. 2408documentation for \f(CW\*(C`ev_default_init\*(C'\fR.
2409.Sp
2410All of the following are about amortised time: If an array needs to be
2411extended, libev needs to realloc and move the whole array, but this
2412happens asymptotically never with higher number of elements, so O(1) might
2413mean it might do a lengthy realloc operation in rare cases, but on average
2414it is much faster and asymptotically approaches constant time.
2409.RS 4 2415.RS 4
2410.IP "Starting and stopping timer/periodic watchers: O(log skipped_other_timers)" 4 2416.IP "Starting and stopping timer/periodic watchers: O(log skipped_other_timers)" 4
2411.IX Item "Starting and stopping timer/periodic watchers: O(log skipped_other_timers)" 2417.IX Item "Starting and stopping timer/periodic watchers: O(log skipped_other_timers)"
2412This means that, when you have a watcher that triggers in one hour and 2418This means that, when you have a watcher that triggers in one hour and
2413there are 100 watchers that would trigger before that then inserting will 2419there are 100 watchers that would trigger before that then inserting will
2416.IX Item "Changing timer/periodic watchers (by autorepeat, again): O(log skipped_other_timers)" 2422.IX Item "Changing timer/periodic watchers (by autorepeat, again): O(log skipped_other_timers)"
2417That means that for changing a timer costs less than removing/adding them 2423That means that for changing a timer costs less than removing/adding them
2418as only the relative motion in the event queue has to be paid for. 2424as only the relative motion in the event queue has to be paid for.
2419.IP "Starting io/check/prepare/idle/signal/child watchers: O(1)" 4 2425.IP "Starting io/check/prepare/idle/signal/child watchers: O(1)" 4
2420.IX Item "Starting io/check/prepare/idle/signal/child watchers: O(1)" 2426.IX Item "Starting io/check/prepare/idle/signal/child watchers: O(1)"
2421These just add the watcher into an array or at the head of a list. If 2427These just add the watcher into an array or at the head of a list.
2422the array needs to be extended libev needs to realloc and move the whole
2423array, but this happen asymptotically less and less with more watchers,
2424thus amortised O(1).
2425.IP "Stopping check/prepare/idle watchers: O(1)" 4
2426.IX Item "Stopping check/prepare/idle watchers: O(1)" 2428=item Stopping check/prepare/idle watchers: O(1)
2427.PD 0
2428.IP "Stopping an io/signal/child watcher: O(number_of_watchers_for_this_(fd/signal/pid % \s-1EV_PID_HASHSIZE\s0))" 4 2429.IP "Stopping an io/signal/child watcher: O(number_of_watchers_for_this_(fd/signal/pid % \s-1EV_PID_HASHSIZE\s0))" 4
2429.IX Item "Stopping an io/signal/child watcher: O(number_of_watchers_for_this_(fd/signal/pid % EV_PID_HASHSIZE))" 2430.IX Item "Stopping an io/signal/child watcher: O(number_of_watchers_for_this_(fd/signal/pid % EV_PID_HASHSIZE))"
2430.PD
2431These watchers are stored in lists then need to be walked to find the 2431These watchers are stored in lists then need to be walked to find the
2432correct watcher to remove. The lists are usually short (you don't usually 2432correct watcher to remove. The lists are usually short (you don't usually
2433have many watchers waiting for the same fd or signal). 2433have many watchers waiting for the same fd or signal).
2434.IP "Finding the next timer per loop iteration: O(1)" 4 2434.IP "Finding the next timer per loop iteration: O(1)" 4
2435.IX Item "Finding the next timer per loop iteration: O(1)" 2435.IX Item "Finding the next timer per loop iteration: O(1)"

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines