Repository navigation
perf(startup): load the code editor only when a code block is drawn - #13631
yuxi-liu-wired wants to merge 3 commits into
Conversation
|
Fixed a real first-load code-block regression in 248a222. Reproduced using the matching locally built nightly: create an empty block and type three backticks with real keyboard events. The language/copy shell appeared, but CodeMirror never mounted. Root cause: Promesa's value factory wraps Shadow's Closure Deferred instead of awaiting its completion. Registration was checked before the module downloaded. The loader now explicitly resolves a Promesa promise from Shadow's completion callback and forwards its errback. Validation sequence:
The emergency fix is also on |
|
Measured this optimization with ablations against upstream, using the same shared warm profile, Xvfb, hyperfine, 20 measured runs per build and CPU settings fixed at 100% with turbo enabled. Whole-command mean ± standard deviation:
The three changes together reproduce the full fork's startup performance. Launch-to-real-home for the three-change build: 2.077 ± 0.017 seconds versus upstream 2.621 ± 0.025 seconds. Code-block first use was checked using real keyboard events: three backticks mount CodeMirror; typing and selection work. Ablation base: 22a29b3. Combined patch: d462a777b0. Raw benchmark JSON and per-run stages are retained locally at All three optimizations are already included in published fork-nightly commit 1771ba4. The lazy editor includes the module-registration completion fix. |
abab695 to
3122e68
Compare
da7561f to
bc7bb30
Compare
The code editor module (`:code-editor`, CodeMirror and its modes) runs on every app open, though it is only needed when a code block is drawn. `resources/index.html` loads `js/code-editor.js` with a `<script>` tag; in a CPU profile of a desktop window reload it took about 360 ms of the renderer's time before the home screen.
`frontend.components.lazy-editor` already loads the module on demand (`shadow.loader/load :code-editor` when a code block mounts). In a release build the module loader resolves the module to `/static/js/code-editor.js`, the dev `:asset-path`, which does not exist beside a packaged `index.html`; the `<script>` tag hid that. The release build now uses `:asset-path "./js"`, so the module is fetched from beside the page, and the tag is removed from `index.html`.
In a desktop release build the module loader table reads `{"code-editor" ["./js/code-editor.js"]}`, and a profile of a reload shows no `code-editor.js` work before the home screen.
bc7bb30 to
5c8eb10
Compare
|
Combined into #13872 with the other PRs of this theme, to keep the number of open PRs down; the commits are unchanged there. |
The code editor module (
:code-editor, CodeMirror and its modes) runs on every app open, though it is only needed when a code block is drawn.resources/index.htmlloadsjs/code-editor.jswith a<script>tag; in a CPU profile of a desktop window reload it took about 360 ms of the renderer's time before the home screen.frontend.components.lazy-editoralready loads the module on demand (shadow.loader/load :code-editorwhen a code block mounts). In a release build the module loader resolves the module to/static/js/code-editor.js, the dev:asset-path, which does not exist beside a packagedindex.html; the<script>tag hid that. The release build now uses:asset-path "./js", so the module is fetched from beside the page, and the tag is removed fromindex.html.In a desktop release build the module loader table reads
{"code-editor" ["./js/code-editor.js"]}, and a profile of a reload shows nocode-editor.jswork before the home screen.