-
Notifications
You must be signed in to change notification settings - Fork 29.2k
Improve web benchmarks measurements #127900
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
Conversation
// Provide COOP/COEP headers so that the browser loads the page as | ||
// crossOriginIsolated. This will make sure that we get high-resolution | ||
// timers for our benchmark measurements. | ||
if (mimeType == 'text/html' || mimeType == 'text/javascript') { |
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.
Should we also add this to flutter run
?
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.
We'll have to address this question eventually, but I think we should really just do this for our benchmarks for now. Enabling crossOriginIsolated
in flutter run
could potentially break clients... we might want to do so conditionally or something. I think we should have a broader conversation about it, but it's probably out of scope of this PR. I'll have to figure this out for skwasm either way.
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 filed #127902 as a follow on
To follow up, Skia Perf is picking up the change: https://flutter-flutter-perf.skia.org/t/?begin=1685500141&end=1685500143&subset=all |
By default, the browser fuzzes the timer APIs such that they have a granularity of approximately 100 microseconds (this is due to Spectre mitigation techniques). However, many of the thing we are trying to measure actually have a much finer granularity than 100 microseconds. As a result, many of our benchmarks are extremely noisy and don't provide accurate data.
By serving the initial script files with the
Cross-Origin-Opener-Policy: same-origin
andCross-Origin-Embedder-Policy: require-corp
HTTP headers, the browser runs the benchmarks in acrossOriginIsolated
context, which restores the fine granularity of APIs such asperformance.now()
to microsecond precision.Also, we were considering anything an outlier that was more than one standard deviation away from the mean. In a normal distribution, that means we are only capturing 68% of the data and the rest are considered outliers. This is not ideal. Doing two standard deviations away captures 95% of the data, and the outliers are in the remaining 5%, which seems much more reasonable.