Package: key-mon
Version: 1.17-1
Severity: minor

On a machine that receives no input (neither mouse nor keyboard),
"key-mon" requires about 10% CPU for me.


I'd have expected it to be event-triggered, so that no polling
would be necessary - seems I'm wrong.

strace shows it being active about a thousand times a second:

    13:23:29.912216 select(0, NULL, NULL, NULL, {tv_sec=0, tv_usec=1000}) = 0 
(Timeout) <0.001099>
    13:23:29.913442 recvmsg(5, {msg_namelen=0}, 0) = -1 EAGAIN  <0.000024>
    13:23:29.913561 recvmsg(5, {msg_namelen=0}, 0) = -1 EAGAIN  <0.000021>
    13:23:29.913665 poll([{fd=5, events=POLLIN}, {fd=6, events=POLLIN}, {fd=8, 
events=POLLIN}, {fd=10, events=POLLIN}], 4, 0) = 0 (Timeout) <0.000034>
    13:23:29.913859 select(0, NULL, NULL, NULL, {tv_sec=0, tv_usec=1000}) = 0 
(Timeout) <0.001111>
    13:23:29.915110 recvmsg(5, {msg_namelen=0}, 0) = -1 EAGAIN  <0.000025>


Changing a single line to

      time.sleep(0.005)

(in /usr/lib/python2.7/dist-packages/keymon/key_mon.py:498)
reduces CPU use to 2%, as expected; still, powertop reports this process 
alone using 0.8W; across the whole system (so including scheduler etc.) 
it's the difference from 2.13W to 3.80W, so nearly halving the battery 
lifetime.

Is there a way to remove the polling completely?


-- System Information:
Debian Release: bullseye/sid
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'unstable'), (500, 'stable'), (1, 
'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 5.4.0-4-amd64 (SMP w/8 CPU cores)
Kernel taint flags: TAINT_WARN
Locale: LANG=de_AT.UTF-8, LC_CTYPE=de_AT.UTF-8 (charmap=UTF-8), 
LANGUAGE=de_AT:de (charmap=UTF-8)
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages key-mon depends on:
ii  python       2.7.17-2
ii  python-gtk2  2.24.0-6
ii  python-xlib  0.26-1

key-mon recommends no packages.

key-mon suggests no packages.

-- no debconf information

-- 

Reply via email to