Skip to content
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

Merged
merged 3 commits into from
Dec 31, 2024

Conversation

mstange
Copy link
Contributor

@mstange mstange commented Dec 13, 2024

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.

@mstange mstange requested a review from julienw December 13, 2024 21:21
Copy link

codecov bot commented Dec 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.61%. Comparing base (6fa213a) to head (df6d128).
Report is 4 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

@mstange mstange force-pushed the push-puyntwqusqyq branch 2 times, most recently from e9e439d to 9a5f97b Compare December 13, 2024 21:45
Copy link
Contributor

@julienw julienw left a 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.

Comment on lines 55 to 61
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,
]);
Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

@mstange mstange Dec 17, 2024

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.

Copy link
Contributor

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!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, after talking to Florian more, I'm no longer convinced that setting the base profiler values to zero is the better outcome. Before, after. I think I'll just update this PR to avoid the behavior change.

Copy link
Contributor Author

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.
@mstange mstange merged commit b86c7c5 into firefox-devtools:main Dec 31, 2024
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants