Bug 433796 - kio_http_cache_cleaner is busy waiting
Summary: kio_http_cache_cleaner is busy waiting
Status: REPORTED
Alias: None
Product: frameworks-kio
Classification: Frameworks and Libraries
Component: HTTP (show other bugs)
Version: git master
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: KIO Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-03-01 15:51 UTC by Harald Sitter
Modified: 2023-02-10 23:59 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Harald Sitter 2021-03-01 15:51:50 UTC
SUMMARY
(this is very poorly researched, but if I don't write it down I'll forget tomorrow)

kio_http_cache_cleaner has a loop that is basically always true and inside it waits for 100ms and then either talks to sockets (on the other end I guess is the http.so) or not. it wraps around and the dance continues.
This effectively is causing entirely pointless CPU load. Not that big a deal on desktops but in the >0.5% range on plasma mobile. Always. Even when idle. My poor battery :(

STEPS TO REPRODUCE
1. run the cleaner

OBSERVED RESULT
watch it doing stuff when there is nothing to do (at least I think there isn't)

EXPECTED RESULT
be completely idle unless there's work to be done

ADDITIONAL INFORMATION
This actually was made worse in a change a while ago that reduced the sleep time from 1s to 100ms because the cleaner wasn't shutting down properly. That did make me wonder why it is busy looping at all though. The application can simply run an eventloop and attach to QLocalServer::newConnection (which I presume will not busy wait) thereby being able to exit somewhat immediately and having zero need for any amount of while(true){} looping.
Comment 1 Oliver Stoeneberg 2023-02-10 23:59:50 UTC
I see something similar with 5.102 on Manjaro Linux with Plasma Mobile.

When the system is idle and no applications are open kio_http_cache_cleaner is constantly in the top 3 in powertop with an Usage of about 0,9 ms/s and Events/s of 9,8.

Terminating the process with SIGTERM doesn't show much of an improvement overall in consumption and CPU load but it still seems quite unnecessary.