stund uses up more cpu than it should
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
stun (Ubuntu) |
Confirmed
|
Undecided
|
Unassigned |
Bug Description
Binary package hint: stun
stund uses 5-8% of the CPU on a pretty fast machine (xen vm on 1/8 of a quad core amd box). Looking at the code, the inner loop looks like this:
struct timeval tv;
tv.tv_sec = 0;
tv.tv_usec = 1000;
int e = select( maxFd, &fdSet, NULL,NULL, &tv );
I don't see any reason the select timeout should be so short. I haven't tested increasing it, but based on the strace output, I'd be shocked if making it larger didn't help.
ProblemType: Bug
Architecture: i386
Date: Fri Aug 8 01:45:49 2008
Dependencies:
libgcc1 1:4.2.3-2ubuntu7
libstdc++6 4.2.3-2ubuntu7
gcc-4.2-base 4.2.3-2ubuntu7
libc6 2.7-10ubuntu3
DistroRelease: Ubuntu 8.04
NonfreeKernelMo
Package: stun 0.96.dfsg-5
PackageArchitec
ProcEnviron:
PATH=/
LANG=en_US.UTF-8
SHELL=/bin/tcsh
SourcePackage: stun
Uname: Linux 2.6.24-19-generic i686
I can confirm both the bug and the solution.
If you look at stun using powertop it shows a lot of useless wakeups because of this loop. I've recompiled the package with modified stun.cxx (see diff code below) and now it does not hog the system. It still works perfectly on our production VOIP server. Please fix.
Regards,
Marius Karthaus
patch:
1408c1408
< tv.tv_usec = 1000000;
---
> tv.tv_usec = 1000;