Skip to content

BenchmarkRunner test measurement refactoring - #28

Closed
camillobruni wants to merge 24 commits into
WebKit:mainfrom
camillobruni:2022-11-22_async_metric
Closed

camillobruni wants to merge 24 commits into
WebKit:mainfrom
camillobruni:2022-11-22_async_metric

Conversation

@camillobruni

@camillobruni camillobruni commented Nov 22, 2022 •

Copy link
Copy Markdown
Contributor
  • Added separate MeasureTask for measuring
  • Added params.asyncMetric to experiment with the existing "timeout"-based and new "raf"-based approach

Comment thread resources/benchmark-runner.mjs Outdated
Comment thread resources/benchmark-runner.mjs Outdated
Comment thread resources/benchmark-runner.mjs Outdated
Comment thread resources/benchmark-runner.mjs Outdated
@camillobruni camillobruni changed the title WIP BenchmarkRunner run refactoring BenchmarkRunner test measurement refactoring Nov 22, 2022
@camillobruni
camillobruni requested a review from rniwa November 22, 2022 22:09
Comment thread resources/tests.mjs
Comment thread resources/benchmark-runner.mjs Outdated
submit(options = NATIVE_OPTIONS)
_dispatchSubmitEvent()
{
// FIXME FireFox doesn't like `new Event('submit')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks like this comment about Firefox is no longer applicable.
We should probably just use dispatchEvent instead.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Which version are you using? FF 107.0 (64-bit) still get's stuck on AngularJS-TodoMVC if I don't use the custom event.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

That is surprising when the c++ code for new Event literally calls initEvent
https://searchfox.org/mozilla-central/rev/670e2e0999f04dc7734c8c12b2c3d420a1e31f12/dom/events/Event.cpp#365-367

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

That is surprising when the c++ code for new Event literally calls initEvent https://searchfox.org/mozilla-central/rev/670e2e0999f04dc7734c8c12b2c3d420a1e31f12/dom/events/Event.cpp#365-367

I agree it's surprising, though I observe the same behavior on Nightly.

Comment thread resources/benchmark-runner.mjs Outdated
Comment thread resources/benchmark-runner.mjs Outdated
Comment thread resources/benchmark-runner.mjs Outdated
Comment thread resources/benchmark-runner.mjs Outdated
Comment thread resources/benchmark-runner.mjs Outdated
Comment thread resources/benchmark-runner.mjs Outdated
Comment thread resources/benchmark-runner.mjs Outdated
@rniwa

rniwa commented Dec 1, 2022

Copy link
Copy Markdown
Member

Could you rebase this against the current main?

@camillobruni

Copy link
Copy Markdown
Contributor Author

Ups, I thought I did that already yesterday.

@camillobruni
camillobruni force-pushed the 2022-11-22_async_metric branch from 4173f00 to 5d28f74 Compare December 1, 2022 22:40
this._recordTestResults(suite, test, syncTime, asyncTime, test_done_callback);
}, 0);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we have before/after numbers among browsers for this change?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've finally had time to run this change against the previous version. I do see a 1% to 2% slowdown. I will have to investigate and see whether I can repro this a bit better to pinpoint the main culprit.

https://docs.google.com/spreadsheets/d/1siPnknDnBh8mx9KJEL_MQrA5OufXUO5cOOX3eDRGBzE/edit?usp=sharing&resourcekey=0-tyHRwrlR0h5Ga0p9xjjYxw

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Have we gotten around to do any analysis on this?

Comment thread resources/benchmark-runner.mjs Outdated
@camillobruni
camillobruni marked this pull request as draft February 16, 2023 22:18
@camillobruni camillobruni mentioned this pull request Mar 9, 2023
camillobruni added a commit that referenced this pull request Mar 9, 2023
- Pre-allocate all mark-label strings to avoid potential gc's during sensitive measurements
- Move code to new separate `_recordTestResults` method in preparation for pr #28
@rniwa

rniwa commented Apr 11, 2023

Copy link
Copy Markdown
Member

We had some internal discussion about this, and we're concerned that the proposed change will make CPU throttle back the frequency too much. In practice, this will result in a paradoxical effect of the slower a software is, the faster CPU gets (because longer running task will tend to keep CPUs busier for a longer period of time and therefore keeps it at a higher frequency). We could work around this problem by warming up CPU with some workload but then that's pretty artificial as well and may have other adverse side effects like triggering thermal throttling of CPU.

The current measurement methodology of Speedometer has an advantage that it lets faster browser keep running at a high CPU frequency after finishing preceding workloads. In effect, it lets us measure the throughput of the browser engine, and not the latency for CPU to ramp up.

@camillobruni

Copy link
Copy Markdown
Contributor Author

We do already see the throttling down in some cases when running over slower networks with the Speedometer 2.1.
So this might be an issue worth addressing.. I'm not too fond of warming up CPUs, maybe we do need some minor cool-down period after loading the resources?

Given that we do need some way to measure async performance, would you be up for landing just the preparatory refactoring without the addditional RAF-based metric for now?

Comment thread resources/benchmark-runner.mjs Outdated
};

class RafBracketedCallbacks {
constructor(first_callback, second_callback) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please use camelCase.

Comment thread resources/benchmark-runner.mjs Outdated
],
};

class RafBracketedCallbacks {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

rAF should probably capitalized as rAF, not Raf.

Comment thread resources/benchmark-runner.mjs Outdated
});
}
if (this._asyncMetricMode === "timeout")
setTimeout(this._measureSync.bind(this), 0);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why don't we wrap this in callbacks class like TimerCallbacks which takes two arguments like RafBracketedCallbacks.

Comment thread resources/benchmark-runner.mjs Outdated
if (this._asyncMetricMode === "timeout")
setTimeout(this._measureAsyncTimeoutCallback, 0);
else
this._rafMeasurement.run();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm confused. Why do we need to call run again here?

constructor(firstCallback, secondCallback) {
this._firstCallback = firstCallback;
this._secondCallback = secondCallback;
this._setTimeoutCallback = this._setTimeout.bind(this);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: I'd find it easier to follow these classes if property name was always _setTimeoutCallback both in the class declaration and in this statement reassigning to the bound function (this._setTimeoutCallback = this._setTimeoutCallback.bind(this);)

this._asyncMeasurePromise = new Promise((resolve) => {
this._asyncDoneCallback = resolve;
});
this._rAFMeasurement = new RAFBracketedCallbacks(this._measureRafStart.bind(this), this._measureRafEnd.bind(this));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Something here is rather confusing. Using RAFBracketedCallbacks in two places with different callbacks.
Why do we need this kind of setup?

@rniwa rniwa added major change A change with major implications on benchmark results or affect governance policy v3-blocker labels May 19, 2023
};

class TimerCallbacks {
constructor(firstCallback, secondCallback) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Call these as first & second are rather confusing.
We should probably call them as syncCallback & asyncCallback.

@rniwa

rniwa commented May 19, 2023 •

Copy link
Copy Markdown
Member

This is getting all so complicated to review. I think we should split this into two pieces.

  1. Refactoring of callbacks
  2. Addition of rAF-based measurement

@rniwa

rniwa commented May 19, 2023 •

Copy link
Copy Markdown
Member

This is getting all so complicated to review. I think we should split this into two pieces.

  1. Refactoring of callbacks
  2. Addition of rAF-based measurement

Alright, I've gone ahead and made a PR for (1): #164

@camillobruni

Copy link
Copy Markdown
Contributor Author

Sorry, just got around to read this after my vacation.
Happy to split this into separate parts.

@rniwa

rniwa commented May 25, 2023

Copy link
Copy Markdown
Member

We've made the equivalent changes in #173 and #164

@rniwa rniwa closed this May 25, 2023
@camillobruni
camillobruni deleted the 2022-11-22_async_metric branch August 6, 2024 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

major change A change with major implications on benchmark results or affect governance policy v3-blocker

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants