[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[tpop3d-discuss][PATCH]: avoid tons of time() calls
From: |
Arkadiusz Miskiewicz |
Subject: |
[tpop3d-discuss][PATCH]: avoid tons of time() calls |
Date: |
Wed, 28 Jun 2006 19:52:08 +0200 |
User-agent: |
KMail/1.9.3 |
Hi,
I've just checked that on busy server I get
nearly 10000 time() calls per second!
# grep 19:36:04 OUT |grep time | wc -l
9668
where OUT is output from strace -tt -f -F -s 200 -p 5571 -o OUT
(5571 is main parent of all tpop3d childs).
Do we need to call it so often?
In most cases if (!(c = connections[i])) will just continue and I see no point
to check time every iteration.
--- netloop.c 2006-06-26 07:30:25.000000000 +0200
+++ netloop.c 2006-06-28 19:46:00.000000000 +0200
@@ -387,16 +387,20 @@
static size_t i;
size_t i0;
time_t start;
+ int latency = 1;
time(&start);
- for (i0 = (i + max_connections - 1) % max_connections; time(NULL) < start
+ LATENCY && i != i0; i = (i + 1) % max_connections) {
+ for (i0 = (i + max_connections - 1) % max_connections; latency && i != i0;
i = (i + 1) % max_connections) {
connection c;
int r;
if (!(c = connections[i]))
continue;
+ if (time(NULL) >= start + LATENCY)
+ latency = 0;
+
if (i > 0 && post_fork) {
connections[0] = c;
connections[i] = NULL;
--
Arkadiusz MiĆkiewicz PLD/Linux Team
arekm / maven.pl http://ftp.pld-linux.org/
- [tpop3d-discuss][PATCH]: avoid tons of time() calls,
Arkadiusz Miskiewicz <=