-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
core(fr): prepare emulation utilities for shared use #12375
Conversation
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.
Worth bikeshedding for a minute? Maybe not, considering the improvement already here over the status quo :)
But:
emulate()
throttle() // Network and CPU
clearThrottling() // Network and CPU
enableNetworkThrottling()
clearNetworkThrottling()
enableCPUThrottling()
clearCPUThrottling()
enableThrottling()
to match clearThrottling
/enableNetworkThrottling
/enableCPUThrottling
? Or were you thinking in terms of matching emulate()
?
@@ -129,7 +130,8 @@ class GatherRunner { | |||
log.time(status); | |||
const resetStorage = !options.settings.disableStorageReset; | |||
await driver.assertNoSameOriginServiceWorkerClients(options.requestedUrl); | |||
await driver.beginEmulation(options.settings); | |||
await emulation.emulate(driver.defaultSession, options.settings); | |||
await emulation.throttle(driver.defaultSession, options.settings); |
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 is a literal translation of the existing driver.beginEmulation
, but could we not throttle here since per-pass throttling is going to be set regardless? I don't think there's any reason to set it here, at least.
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.
Sure, SG
// TODO(FR-COMPAT): reconsider if this should be resetting anything | ||
if (settings.throttlingMethod !== 'devtools') return clearNetworkThrottling(session); |
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.
seems more like a gather-runner
concern than an emulation utility. Could we move out to there and keep this a little more separated?
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.
My response here is tightly related to my reflection on the poll so I'll respond to both here.
enableThrottling won the informal poll, so we'll rename throttle to that
Looking at this more closely, I don't think enableThrottling
is right. The emulate
and throttle
methods aren't blindly turning on the emulation/throttling protocol methods, they're looking at config settings and setting what needs to be set according to the config settings.
A new method called enableThrottling
that accepts the throttling
object from settings that just calls the two makes sense, but at that point honestly why bother having a method at all?
I think your argument @brendankenny is that this logic should move up a layer into gather-runner but one of the goals here explicitly was to extract the shared parts for FR and at least for now all of this should be shared logic. Given that, I'm not sure I agree there's a benefit to having this live one layer up (it's not like we're mixing in the passConfig
object like we were previously, there I wholeheartedly agree it shouldn't live in shared lib/
).
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.
Looking at this more closely, I don't think
enableThrottling
is right.
conveniently realized after the vote is closed :P
A new method called
enableThrottling
that accepts thethrottling
object from settings that just calls the two makes sense, but at that point honestly why bother having a method at all?
Ha, you wouldn't have to twist my arm on this if this is the direction you actually wanted to go ;) The clear*Throttling
methods are basically already there.
I think it's the fact that it's exactly the same condition as if (passConfig.useThrottling) emulation.throttle(); else emulation.clearThrottling();
that ran right before this line that trips me up. If I were writing this as new code but wanted to match current behavior, I would go with if (passConfig.useThrottling && settings.throttlingMethod === 'devtools') ...
in the caller in this case (which matches the pass-centric view "in this pass, enable throttling if throttlingMethod
is 'devtools'
and it's enabled for this pass").
I can easily see the arguments you're making here too, though, so this seems good to go. From the TODO(FR-COMPAT)
and WPT-compat
comments, those conditions might not end up doing the same thing anyways.
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 would go with if (passConfig.useThrottling && settings.throttlingMethod === 'devtools')
I'm fine with that. Deal. You had me convinced until I looked at the code again, it's not the same condition! See below
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.
Wait nevermind it's not the same condition, that's why I was putting this fight up in the first place :P
It's super specific that we only clear the network but not the CPU when we're doing other throttlingMethods. If that changes in FR I'm happy to move toward your suggestion, but for now that super specific detail feels like it should stay with throttle
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.
It's super specific that we only clear the network but not the CPU when we're doing other throttlingMethods. If that changes in FR I'm happy to move toward your suggestion, but for now that super specific detail feels like it should stay with throttle
oh right, lord. We need to clear up what's going on with that :)
|
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.
LGTM
// TODO(FR-COMPAT): reconsider if this should be resetting anything | ||
if (settings.throttlingMethod !== 'devtools') return clearNetworkThrottling(session); |
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.
Looking at this more closely, I don't think
enableThrottling
is right.
conveniently realized after the vote is closed :P
A new method called
enableThrottling
that accepts thethrottling
object from settings that just calls the two makes sense, but at that point honestly why bother having a method at all?
Ha, you wouldn't have to twist my arm on this if this is the direction you actually wanted to go ;) The clear*Throttling
methods are basically already there.
I think it's the fact that it's exactly the same condition as if (passConfig.useThrottling) emulation.throttle(); else emulation.clearThrottling();
that ran right before this line that trips me up. If I were writing this as new code but wanted to match current behavior, I would go with if (passConfig.useThrottling && settings.throttlingMethod === 'devtools') ...
in the caller in this case (which matches the pass-centric view "in this pass, enable throttling if throttlingMethod
is 'devtools'
and it's enabled for this pass").
I can easily see the arguments you're making here too, though, so this seems good to go. From the TODO(FR-COMPAT)
and WPT-compat
comments, those conditions might not end up doing the same thing anyways.
Summary
Broken out of #12366, just the emulation shared pieces. We already basically had this split in
lib/emulation.js
so it was just moving the last two methods that put it together :)Related Issues/PRs
ref #11313 #12366