Skip to content

Commit 6d9164e

Browse files
jackfranklinDevtools-frontend LUCI CQ
authored andcommitted
RPP: disable throttling during trace collection
We have had reports of the performance panel freezing for users when CPU throttling is active; particularly with the new 20x throttling option. We think this is because after tracing is completed the act of collecting + emitting all the events from the renderer (which is what gets throttled) is very slow. This is less prevalent on big powerful M3 MacBooks but more prevalent on less powerful devices, and also more prevalent on heavier websites which generate more trace events. This CL updates the code so that after we stop tracing we immediately reset the CPU throttling to 1 (e.g. no throttling). Then, after all the events are gathered and collected, we set it back to whatever it was. This maintains the existing behaviour of the throttling being persistent in Devtools, but means we do not throttle during a potentially expensive stage of the process. Testing (unscientifically) on my M1 MacBook Pro on cnn.com with 20x throttling, I got: - Between 9.5-11 seconds of processing time with NO change - Between 5-5.5 seconds of processing time with this CL And I am fairly confident these numbers will be larger on less powerful devices. As a drive-by, I also updated the throttling manager to make sure that if you set the CPU throttling to what it is already, it does nothing rather than fire off a bunch of listeners despite the value not actually changing. Fixed: 376836355 Change-Id: Ie7bf7fdfca1039b549b16ae94c486189a7b3abd0 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/5979761 Reviewed-by: Connor Clark <[email protected]> Commit-Queue: Paul Irish <[email protected]> Reviewed-by: Paul Irish <[email protected]>
1 parent 69c141f commit 6d9164e

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

front_end/core/sdk/CPUThrottlingManager.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ export class CPUThrottlingManager extends Common.ObjectWrapper.ObjectWrapper<Eve
3535
}
3636

3737
setCPUThrottlingRate(rate: number): void {
38+
if (rate === this.#cpuThrottlingRateInternal) {
39+
return;
40+
}
41+
3842
this.#cpuThrottlingRateInternal = rate;
3943
for (const emulationModel of TargetManager.instance().models(EmulationModel)) {
4044
void emulationModel.setCPUThrottlingRate(this.#cpuThrottlingRateInternal);

front_end/panels/timeline/TimelineController.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,23 @@ export class TimelineController implements Trace.TracingManager.TracingManagerCl
144144
if (this.tracingManager) {
145145
this.tracingManager.stop();
146146
}
147+
// When throttling is applied to the main renderer, it can slow down the
148+
// collection of trace events once tracing has completed. Therefore we
149+
// temporarily disable throttling whilst the final trace event collection
150+
// takes place. Once it is done, we re-enable it (this is the existing
151+
// behaviour within DevTools; the throttling settling is sticky + global).
152+
const throttlingManager = SDK.CPUThrottlingManager.CPUThrottlingManager.instance();
153+
const rateDuringRecording = throttlingManager.cpuThrottlingRate();
154+
// 1 = no throttling (CPU is 1x'd)
155+
throttlingManager.setCPUThrottlingRate(1);
147156

148157
this.client.loadingStarted();
149158
await this.waitForTracingToStop();
150159
await this.allSourcesFinished();
151160

161+
// Now we re-enable throttling again to maintain the setting being persistent.
162+
throttlingManager.setCPUThrottlingRate(rateDuringRecording);
163+
152164
await LiveMetrics.LiveMetrics.instance().enable();
153165
}
154166

0 commit comments

Comments
 (0)