Modify
Warning Please read the Ticket HowTo before creating or commenting on a ticket. Failure to do so may cause your ticket to be rejected or result in a slower response.

Opened 17 months ago

Closed 15 months ago

Last modified 15 months ago

#11255 closed Patch - Feature (fixed)

Change MythTimer to use monotonic clock

Reported by: Rune Petersen <rune@…> Owned by: danielk
Priority: minor Milestone: 0.27
Component: MythTV - General Version: 0.26-fixes
Severity: medium Keywords: performance
Cc: Ticket locked: no

Description

Currently MythTimer? is implemented using QTime which relies on system time and timezone conversion have the following problems:

  • imprecise if system time is changed
  • imprecise if if a change to/from DST happens

The patch uses QElapsedTimer instead of QTime.
QElapsedTimer relies on monotonic clock, "get ticks" or similar.

Known problems with this patch:

  • QElapsedTimer requires QT 4.7 (what is currently the minimum requirement?)
  • addMSecs() cannot be implemented with QElapsedTimer, but then again the current implementation is a no-op.

This patch reduces CPU usage by ~5% on a 700MHz Cortex-A9 when recording DVB HD content.

Attachments (1)

mythtv_mythtimer_use_monotonic_clock.patch (1.2 KB) - added by Rune Petersen <rune@…> 17 months ago.

Download all attachments as: .zip

Change History (7)

Changed 17 months ago by Rune Petersen <rune@…>

comment:1 Changed 17 months ago by stichnot

  • Owner set to danielk
  • Status changed from new to assigned

comment:2 Changed 15 months ago by Daniel Thor Kristjansson <danielk@…>

  • Resolution set to fixed
  • Status changed from assigned to closed

In 440573f3febdc8009b74ae1b2366aa7d518a15a7/mythtv:

Convert MythTimer? to use QElapsedTimer instead of QTime.

Fixes #11255.

We initially created MythTimer? because QTime isn't monotonic
and we wanted a wrapper that assured that time wouldn't march
backward too much. As of Qt 4.7 there is a timer available
which is monotonic on most systems. This converts MythTimer?
to use this new timer.

The first version of this new wrapper was written by
Rune Petersen for the efficiency gains this has over
QTime which does an expensive DST conversion internally.
I added back a timer restart in the elapsed() method
since QElapsedTimer doesn't always provide a monotonic
timer, and I implemented the addMSecs() method so this
could be used in all instances where the original
MythTimer? was used.

comment:3 Changed 15 months ago by Daniel Thor Kristjansson <danielk@…>

comment:4 Changed 15 months ago by Rune Petersen <rune@…>

Thank you Daniel

comment:5 Changed 15 months ago by Daniel Thor Kristjansson <danielk@…>

In 926464a3f11448689523db3441515ef3c6bd8ce8/mythtv:

Fix a misuse of MythTimer?.

This was what forced the [94028580] workaround earlier this week.

Refs #11255.

comment:6 Changed 15 months ago by wagnerrp

  • Milestone changed from unknown to 0.27

Add Comment

Modify Ticket

Action
as closed .
The resolution will be deleted. Next status will be 'new'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.