Bug 433785 - Greeter constantly getting date time using time dataengine, wasting CPU
Summary: Greeter constantly getting date time using time dataengine, wasting CPU
Status: CONFIRMED
Alias: None
Product: plasmashell
Classification: Plasma
Component: Screen locking (show other bugs)
Version: 6.2.4
Platform: Other Linux
: NOR normal
Target Milestone: 1.0
Assignee: Plasma Bugs List
URL:
Keywords: efficiency
Depends on:
Blocks:
 
Reported: 2021-03-01 11:13 UTC by Harald Sitter
Modified: 2024-12-18 19:02 UTC (History)
4 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 11:13:01 UTC
SUMMARY
The greeter (through the time dataengine) constantly polls the currentdatetime even when that cannot possibly have changed because only a second passed but the greeter only displays minute precision. On a desktop system that's not really causing much. On the pinephone with plasma mobile it constantly consumes almost 1% CPU with the associated power draw of that.

STEPS TO REPRODUCE
1. gdb or strace the greeter
2. watch QDateTime::currentDateTime

OBSERVED RESULT
time gets polled constantly

EXPECTED RESULT
time ought to only get polled once a minute +-

ADDITIONAL INFORMATION
Seeing as data engines are on their way out anyway it may be prudent to port away from the engine and instead use a QTimer+QTime::currentTime directly. Adjusting the interval after every timeout for the current delay. That way we'd get to exactly one wake up per minute directly related to the then necessary redraw of the time.

auto c = QTime::currentTime();
timer.setInterval(60000 - c.msec());

or something like that

Tracey from plamo for the record
#0  0x0000ffff8c948618 in __kernel_gettimeofday ()
#1  0x0000ffff8a4b2c94 in QDateTime::currentMSecsSinceEpoch() () at /usr/lib/libQt5Core.so.5
#2  0x0000ffff8a4b32f0 in QDateTime::currentDateTime() () at /usr/lib/libQt5Core.so.5
#3  0x0000ffff74ec8f90 in  () at /usr/lib/qt/plugins/plasma/dataengine/plasma_engine_time.so
#4  0x0000ffff74ec7098 in  () at /usr/lib/qt/plugins/plasma/dataengine/plasma_engine_time.so
#5  0x0000ffff7c127390 in  () at /usr/lib/libKF5Plasma.so.5
#6  0x0000ffff8a63cccc in  () at /usr/lib/libQt5Core.so.5
#7  0x0000ffff7c1230f8 in Plasma::DataContainer::updateRequested(Plasma::DataContainer*) () at /usr/lib/libKF5Plasma.so.5
#8  0x0000ffff7c130a9c in  () at /usr/lib/libKF5Plasma.so.5
#9  0x0000ffff8a630868 in QObject::event(QEvent*) () at /usr/lib/libQt5Core.so.5
#10 0x0000ffff8a5f807c in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /usr/lib/libQt5Core.so.5
#11 0x0000ffff8a664ad8 in QTimerInfoList::activateTimers() () at /usr/lib/libQt5Core.so.5
#12 0x0000ffff8a665654 in  () at /usr/lib/libQt5Core.so.5
#13 0x0000ffff88731ce0 in g_main_context_dispatch () at /usr/lib/libglib-2.0.so.0
#14 0x0000ffff887322c0 in  () at /usr/lib/libglib-2.0.so.0
c#15 0x0000ffff887323c4 in g_main_context_iteration () at /usr/lib/libglib-2.0.so.0
#16 0x0000ffff8a665a08 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt5Core.so.5
#17 0x0000ffff8a5f61d4 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt5Core.so.5
#18 0x0000ffff8a600900 in QCoreApplication::exec() () at /usr/lib/libQt5Core.so.5
#19 0x0000aaaac94bb1d4 in  ()
#20 0x0000ffff89fba538 in __libc_start_main () at /usr/lib/libc.so.6
#21 0x0000aaaac94bb574 in _start (
Comment 1 David Edmundson 2021-03-01 12:14:30 UTC
>Seeing as data engines are on their way out anyway it may be prudent to port away from the engine and instead use a QTimer+QTime::currentTime directly


There's code in the dataengine to watch for "skew events" such as being suspended and resumed, and we also have code for timezone changes.

There's also code in the abstract dataengine to align events to the minute.

I'm all for creating a new plugin to do this, rather than fixing the engine, but please don't replace with a pure QML solution as it will miss features.