Improving DevTools startup time
DevTools startup now is ~13% faster 🎉 (from 11.2s down to 10s) #
TL;DR; The result is achieved by removing a redundant serialization.
The mechanism Chromium uses to send DevTools commands to V8 (and for IPC in general) is called
mojo. My teammates Benedikt Meurer and Sigurd Schneider discovered an inefficiency while working on another task, and came up with an idea to improve the process by removing two redundant steps in how these messages are sent and received.
Let us dive into how the
mojo mechanism works!
mojo mechanisms #
There is a mojo command
EvaluateScript which runs the JS command. It serializes the whole JS command including the
Benedikt Meurer realised that serialisation and deserialisation of the
arguments is quite expensive, and that the whole "Serialize JS command to JS string" and "Deserialize JS string" steps are redundant and can be skipped.
How we improved #
For technical details on how we implemented this optimization, consult these two patches:
- CL 2431864: [devtools] Reduce performance overhead of message dispatch in the front-end
- CL 2442012: [devtools] Use
For both revisions, we ran the following scenario 5 times:
- Record trace using
- Open DevTools-on-DevTools
- Get the recorded
CrRendererMaintrace and compare the V8-specific metrics.
Based on these experiments, DevTools opens ~13% faster (from 11.2s down to 10s) with the optimization.
Hightlights, CPU durations #
|Method name||Not optimized (ms)||Optimized (ms)||Differences (ms)||Speed improvement (%)|
As a result, DevTools opens and works faster with less CPU usage. 🎉