summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ev.36
-rw-r--r--ev.c20
-rw-r--r--ev.html9
-rw-r--r--ev.pod7
4 files changed, 35 insertions, 7 deletions
diff --git a/ev.3 b/ev.3
index 01e5c65..d718a09 100644
--- a/ev.3
+++ b/ev.3
@@ -2120,6 +2120,12 @@ defined to be \f(CW0\fR, then they are not.
If you need to shave off some kilobytes of code at the expense of some
speed, define this symbol to \f(CW1\fR. Currently only used for gcc to override
some inlining decisions, saves roughly 30% codesize of amd64.
+.IP "\s-1EV_PID_HASHSIZE\s0" 4
+.IX Item "EV_PID_HASHSIZE"
+\&\f(CW\*(C`ev_child\*(C'\fR watchers use a small hash table to distribute workload by
+pid. The default size is \f(CW16\fR (or \f(CW1\fR with \f(CW\*(C`EV_MINIMAL\*(C'\fR), usually more
+than enough. If you need to manage thousands of children you might want to
+increase this value.
.IP "\s-1EV_COMMON\s0" 4
.IX Item "EV_COMMON"
By default, all watchers have a \f(CW\*(C`void *data\*(C'\fR member. By redefining
diff --git a/ev.c b/ev.c
index f868d7e..8911cb8 100644
--- a/ev.c
+++ b/ev.c
@@ -158,6 +158,14 @@ extern "C" {
# define EV_USE_PORT 0
#endif
+#ifndef EV_PID_HASHSIZE
+# if EV_MINIMAL
+# define EV_PID_HASHSIZE 1
+# else
+# define EV_PID_HASHSIZE 16
+# endif
+#endif
+
/**/
#ifndef CLOCK_MONOTONIC
@@ -178,7 +186,6 @@ extern "C" {
#define MIN_TIMEJUMP 1. /* minimum timejump that gets detected (if monotonic clock available) */
#define MAX_BLOCKTIME 59.743 /* never wait longer than this time (to detect time jumps) */
-#define PID_HASHSIZE 16 /* size of pid hash table, must be power of two */
/*#define CLEANUP_INTERVAL (MAX_BLOCKTIME * 5.) /* how often to try to free memory and re-check fds */
#ifdef EV_H
@@ -711,7 +718,7 @@ siginit (EV_P)
/*****************************************************************************/
-static ev_child *childs [PID_HASHSIZE];
+static ev_child *childs [EV_PID_HASHSIZE];
#ifndef _WIN32
@@ -722,7 +729,7 @@ child_reap (EV_P_ ev_signal *sw, int chain, int pid, int status)
{
ev_child *w;
- for (w = (ev_child *)childs [chain & (PID_HASHSIZE - 1)]; w; w = (ev_child *)((WL)w)->next)
+ for (w = (ev_child *)childs [chain & (EV_PID_HASHSIZE - 1)]; w; w = (ev_child *)((WL)w)->next)
if (w->pid == pid || !w->pid)
{
ev_priority (w) = ev_priority (sw); /* need to do it *now* */
@@ -753,7 +760,8 @@ childcb (EV_P_ ev_signal *sw, int revents)
ev_feed_event (EV_A_ (W)sw, EV_SIGNAL);
child_reap (EV_A_ sw, pid, pid, status);
- child_reap (EV_A_ sw, 0, pid, status); /* this might trigger a watcher twice, but feed_event catches that */
+ if (EV_PID_HASHSIZE > 1)
+ child_reap (EV_A_ sw, 0, pid, status); /* this might trigger a watcher twice, but feed_event catches that */
}
#endif
@@ -1627,7 +1635,7 @@ ev_child_start (EV_P_ ev_child *w)
return;
ev_start (EV_A_ (W)w, 1);
- wlist_add ((WL *)&childs [w->pid & (PID_HASHSIZE - 1)], (WL)w);
+ wlist_add ((WL *)&childs [w->pid & (EV_PID_HASHSIZE - 1)], (WL)w);
}
void
@@ -1637,7 +1645,7 @@ ev_child_stop (EV_P_ ev_child *w)
if (expect_false (!ev_is_active (w)))
return;
- wlist_del ((WL *)&childs [w->pid & (PID_HASHSIZE - 1)], (WL)w);
+ wlist_del ((WL *)&childs [w->pid & (EV_PID_HASHSIZE - 1)], (WL)w);
ev_stop (EV_A_ (W)w);
}
diff --git a/ev.html b/ev.html
index c5df51e..5bcffd0 100644
--- a/ev.html
+++ b/ev.html
@@ -6,7 +6,7 @@
<meta name="description" content="Pod documentation for libev" />
<meta name="inputfile" content="&lt;standard input&gt;" />
<meta name="outputfile" content="&lt;standard output&gt;" />
- <meta name="created" content="Tue Nov 27 11:59:06 2007" />
+ <meta name="created" content="Tue Nov 27 20:23:27 2007" />
<meta name="generator" content="Pod::Xhtml 1.57" />
<link rel="stylesheet" href="http://res.tst.eu/pod.css"/></head>
<body>
@@ -1998,6 +1998,13 @@ defined to be <code>0</code>, then they are not.</p>
speed, define this symbol to <code>1</code>. Currently only used for gcc to override
some inlining decisions, saves roughly 30% codesize of amd64.</p>
</dd>
+ <dt>EV_PID_HASHSIZE</dt>
+ <dd>
+ <p><code>ev_child</code> watchers use a small hash table to distribute workload by
+pid. The default size is <code>16</code> (or <code>1</code> with <code>EV_MINIMAL</code>), usually more
+than enough. If you need to manage thousands of children you might want to
+increase this value.</p>
+ </dd>
<dt>EV_COMMON</dt>
<dd>
<p>By default, all watchers have a <code>void *data</code> member. By redefining
diff --git a/ev.pod b/ev.pod
index 17484ff..5b0835d 100644
--- a/ev.pod
+++ b/ev.pod
@@ -1999,6 +1999,13 @@ If you need to shave off some kilobytes of code at the expense of some
speed, define this symbol to C<1>. Currently only used for gcc to override
some inlining decisions, saves roughly 30% codesize of amd64.
+=item EV_PID_HASHSIZE
+
+C<ev_child> watchers use a small hash table to distribute workload by
+pid. The default size is C<16> (or C<1> with C<EV_MINIMAL>), usually more
+than enough. If you need to manage thousands of children you might want to
+increase this value.
+
=item EV_COMMON
By default, all watchers have a C<void *data> member. By redefining