ports/54835: inefficient timer in healthd
Andriy Gapon
avg at icyb.net.ua
Fri Jul 25 05:20:12 UTC 2003
>Number: 54835
>Category: ports
>Synopsis: inefficient timer in healthd
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-ports-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Thu Jul 24 22:20:08 PDT 2003
>Closed-Date:
>Last-Modified:
>Originator: Andriy Gapon
>Release: FreeBSD 4.8-RELEASE i386
>Organization:
>Environment:
System: FreeBSD edge.foundation.invalid 4.8-RELEASE FreeBSD 4.8-RELEASE #5: Wed Jun 25 19:32:36 EDT 2003
healthd-0.6.9
>Description:
healthd has a very inefficient way of timing interval between measurements
>How-To-Repeat:
run healthd in a daemon mode with 10sec interval between measurements,
observe how much CPU time it consumes,
make conclusions
>Fix:
unfortunately I have not received any response from the author, so I am
submitting a patch here.
--- 2-healthd.c.patch begins here ---
--- healthd.c.orig Mon Jul 7 20:59:46 2003
+++ healthd.c Mon Jul 7 21:46:38 2003
@@ -636,16 +636,15 @@
FD_SET(sock, &ready);
}
}
- to.tv_sec = 0;
- if (sec <= 3) {
- /* For quick reading we need quicker timeouts */
- to.tv_usec = 100;
- } else if (sec <= 10) {
- /* Still want reasonable accuracy */
- to.tv_usec = 500;
- } else {
- /* Let us reduce CPU ussage */
- to.tv_usec = 1000;
+ gettimeofday(&to, 0);
+ to.tv_sec = now + sec - to.tv_sec;
+ if (to.tv_usec > 0) {/* most usual case */
+ to.tv_sec -= 1;
+ to.tv_usec = 1000000 - to.tv_usec;
+ }
+ if (to.tv_sec < 0) {/* somehow we are already late */
+ to.tv_sec = 0;
+ to.tv_usec = 0;
}
if (select(50, &ready, 0, 0, &to) < 0) {
if (ExitProgram) {
--- 2-healthd.c.patch ends here ---
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-ports-bugs
mailing list