-
Notifications
You must be signed in to change notification settings - Fork 405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplify some code related to thread CPU deltas #5265
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #5265 +/- ##
==========================================
- Coverage 88.62% 88.61% -0.01%
==========================================
Files 308 308
Lines 28105 28095 -10
Branches 7621 7618 -3
==========================================
- Hits 24908 24897 -11
- Misses 2983 2984 +1
Partials 214 214 ☔ View full report in Codecov by Sentry. |
e9e439d
to
9a5f97b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks reasonable to me, but I'd very much like to have feedback from Nazım, because he knows a lot more about the CPU values than I do. Unfortunately he's now away until next year, I hope that's OK.
src/test/unit/cpu.test.js
Outdated
expect(processedThread1.samples.threadCPUDelta).toEqual([ | ||
0.1, 0.1, 0.1, 0.2, 0.2, 0.2, | ||
0.1, 0, 0, 0, 0, 0.2, | ||
]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From my understanding:
- before we were treating "null" as "I don't know", and as a result we were, in a way, splitting the "I don't know" hole in half, with the first half using the previous value, and the second half using the next value.
- With your change, the "I don't know part" is transformed into a "0".
I don't know if that's OK. Especially I don't know how common it is to have null
values and what that means. I'd like to have Nazim feedback on this, if that's OK?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After checking 1000 profiles, I have found the following:
- There can be more than one
null
value at the start of the array. - In every checked profile, once you see a non-
null
value, the rest of the values are also non-null
.
And the reason for multiple null
values at the beginning appears to be that we never implemented threadCPUDelta in the base profiler! So during process startup, you get all nulls until the non-base profiler takes over. Example: https://share.firefox.dev/4iG7vsj
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given Florian's confusion in bug 1756519, I would say zeroing out the base profiler values is preferable over what we do today: It'll be more obviously-wrong and less plausible-but-wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the investigation, this sounds good to me!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've removed the first commit. This has the effect that, since getMaxThreadCPUDeltaPerMs
no longer looks at the processed CPU deltas, it might return a value that's lower than the maximum cpu delta per ms once the null substitution has happened:
Let's say you have this unprocessed data: [{ timeDelta: 1, cpuDelta: null }, { timeDelta: 10, cpuDelta: 10 }]
Then you replace the null
with the 10.
Now the first value has { timeDelta: 1, cpuDelta: 10 }
, i.e. 10 CPU per ms. getMaxThreadCPUDeltaPerMs
will now just compute 1 CPU per ms.
I think that's ok because this situation is broken anyway.
…rval. This also fixes the situation where computeMaxThreadCPUDeltaPerMs said it should be called after processing the thread CPU deltas, but computeMaxCPUDeltaPerInterval was calling it before processing.
The loop skips i === 0 so the value was never used.
1930cbf
to
df6d128
Compare
There was a mismatch in whether
computeMaxThreadCPUDeltaPerMs
was called before or after thread CPU delta processing. It didn't make a difference in practice, but it's better to just always call it with the unprocessed values. This will avoid problems if we end up giving the processed values a different type.