Merge lp:~aacid/qtmir/unlikelyResetStartTime into lp:~aacid/qtmir/timestampsInPast

Proposed by Albert Astals Cid on 2015-12-15
Status: Superseded
Proposed branch: lp:~aacid/qtmir/unlikelyResetStartTime
Merge into: lp:~aacid/qtmir/timestampsInPast
Diff against target: 16 lines (+3/-3)
1 file modified
src/common/timestamp_impl.h (+3/-3)
To merge this branch: bzr merge lp:~aacid/qtmir/unlikelyResetStartTime
Reviewer Review Type Date Requested Status
Gerry Boland (community) Approve on 2016-01-07
Albert Astals Cid Pending
Review via email: mp+280569@code.launchpad.net

This proposal has been superseded by a proposal from 2016-01-07.

Commit Message

Provide branch prediction information to the if in compressTimestamp

Description of the Change

 * Are there any related MPs required for this MP to build/function as expected?
Prerequisite

 * Did you perform an exploratory manual test run of your code change and any related functionality?
Yes

 * If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
N/A

To post a comment you must log in.
Albert Astals Cid (aacid) wrote :

This seems a pretty hot path and 99.999% of the times the if evaluates to false so i thought it might make sense telling the compiler to optimize for that.

431. By Albert Astals Cid on 2015-12-15

Use Qt's unlikely define since we're already using Qt here

Gerry Boland (gerboland) :
review: Approve

Unmerged revisions

431. By Albert Astals Cid on 2015-12-15

Use Qt's unlikely define since we're already using Qt here

430. By Albert Astals Cid on 2015-12-15

Provide branch prediction information to the if in compressTimestamp

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/common/timestamp_impl.h'
2--- src/common/timestamp_impl.h 2015-12-15 11:04:54 +0000
3+++ src/common/timestamp_impl.h 2015-12-15 11:25:54 +0000
4@@ -15,9 +15,9 @@
5 {
6 std::chrono::nanoseconds startTime = getStartTime(timestamp);
7
8- if ((std::chrono::nanoseconds::max() > T::max() &&
9- timestamp - startTime > std::chrono::nanoseconds(T::max()))
10- || timestamp < startTime) {
11+ if (Q_UNLIKELY((std::chrono::nanoseconds::max() > T::max() &&
12+ timestamp - startTime > std::chrono::nanoseconds(T::max()))
13+ || timestamp < startTime)) {
14 // we've overflowed the boundaries of the millisecond type.
15 // or the timestamp has travelled to the past
16 resetStartTime(timestamp);

Subscribers

People subscribed via source and target branches

to all changes: