Repository navigation
perf(electron): keep compiled page scripts across app opens - #13634
Merged
Merged
Conversation
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Oct 6, 2026
On every desktop app open, the renderer compiles `js/main.js` (16 MB) from scratch. Chromium keeps V8's compiled code for page scripts between runs in the profile's `Code Cache`, but only for scripts loaded over a scheme registered with the `codeCache` privilege; the app loads `index.html` and its scripts over its own `lsp://` scheme, registered without it. In a profile opened 4 times, `Code Cache` stayed at 36 KB, with nothing for `main.js`; a CPU profile of a window load shows about 30 percent of the renderer's time before the home screen as `(program)`, V8 parsing and compiling. `lsp://` is now registered with `codeCache: true`. After the first open, `Code Cache` holds `main.js`'s compiled code (19 MB, 26 entries) and later opens use it. Measured in a Linux desktop build, from launch, 6 opens of each build alternating, each started with the CPU at full clock: the page's API is ready after 1015 ms instead of 1344 ms (median), and the home screen is drawn after 1611 ms instead of 1965 ms. `Code Cache` after 3 opens: 36 KB before, 20 MB after.
tiensonqin
force-pushed
the
perf/open-code-cache
branch
from
October 7, 2026 11:29
fd5efad to
8f87099
Compare
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Oct 8, 2026
devin-ai-integration Bot
pushed a commit
that referenced
this pull request
Oct 8, 2026
On every desktop app open, the renderer compiles `js/main.js` (16 MB) from scratch. Chromium keeps V8's compiled code for page scripts between runs in the profile's `Code Cache`, but only for scripts loaded over a scheme registered with the `codeCache` privilege; the app loads `index.html` and its scripts over its own `lsp://` scheme, registered without it. In a profile opened 4 times, `Code Cache` stayed at 36 KB, with nothing for `main.js`; a CPU profile of a window load shows about 30 percent of the renderer's time before the home screen as `(program)`, V8 parsing and compiling. `lsp://` is now registered with `codeCache: true`. After the first open, `Code Cache` holds `main.js`'s compiled code (19 MB, 26 entries) and later opens use it. Measured in a Linux desktop build, from launch, 6 opens of each build alternating, each started with the CPU at full clock: the page's API is ready after 1015 ms instead of 1344 ms (median), and the home screen is drawn after 1611 ms instead of 1965 ms. `Code Cache` after 3 opens: 36 KB before, 20 MB after.
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Oct 11, 2026
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Oct 11, 2026
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Oct 13, 2026
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Oct 13, 2026
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Oct 16, 2026
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Oct 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On every desktop app open, the renderer compiles
js/main.js(16 MB) from scratch. Chromium keeps V8's compiled code for page scripts between runs in the profile'sCode Cache, but only for scripts loaded over a scheme registered with thecodeCacheprivilege; the app loadsindex.htmland its scripts over its ownlsp://scheme, registered without it. In a profile opened 4 times,Code Cachestayed at 36 KB, with nothing formain.js; a CPU profile of a window load shows about 30 percent of the renderer's time before the home screen as(program), V8 parsing and compiling.lsp://is now registered withcodeCache: true. After the first open,Code Cacheholdsmain.js's compiled code (19 MB, 26 entries) and later opens use it.Measured with a Linux release build under Xvfb, from launch, the two builds' opens alternating, each started with the CPU at full clock (median of 6 opens with the change, 4 without): the page's API is ready after 1015 ms instead of 1344 ms, and the home screen is drawn after 1611 ms instead of 1965 ms.
Code Cacheafter 3 opens: 36 KB before, 20 MB after.