victronenergy / venus

Victron Energy Unix/Linux OS
https://github.com/victronenergy/venus/wiki
578 stars 72 forks source link

vedirect-dbus, mk2-dbus: busy looping #1213

Closed smurfix closed 7 months ago

smurfix commented 8 months ago

The main loop of vedirect-dbus and mk2-dbus (and possibly others) twiddles its thumbs when it's got nothing to do.

This generates unnecessary load and slows down the rest of the system. Please fix.

# ps 1807
  PID TTY      STAT   TIME COMMAND
 1807 ?        S    1401:04 /opt/victronenergy/vedirect-interface/vedirect-dbus -v --log-before […]
# strace -f -s300 -p1807
strace: Process 1807 attached
epoll_wait(3, [], 32, 35)               = 0
epoll_wait(3, [], 32, 0)                = 0
epoll_wait(3, [], 32, 49)               = 0
epoll_wait(3, [], 32, 1)                = 0
epoll_wait(3, [], 32, 0)                = 0
epoll_wait(3, [], 32, 49)               = 0
epoll_wait(3, [], 32, 0)                = 0
epoll_wait(3, [], 32, 47)               = 0
epoll_wait(3, [], 32, 0)                = 0
epoll_wait(3, [], 32, 49)               = 0
epoll_wait(3, [], 32, 0)                = 0
epoll_wait(3, [], 32, 47)               = 0
epoll_wait(3, [], 32, 0)                = 0
epoll_wait(3, [], 32, 49)               = 0
epoll_wait(3, [], 32, 0)                = 0
epoll_wait(3, [], 32, 47)               = 0
epoll_wait(3, [], 32, 0)                = 0
^C
# 
mpvader commented 7 months ago

Hi @smurfix there might be an improvement here, but this just is what it is.

The same code is used on different platforms (mcus) and there we run it at a 50ms tick counter.

Perhaps some day we'll improve it but I'm not going to keep an issue open for it.

thanks!