Skip to content

perf(electron): keep compiled page scripts across app opens - #13634

Merged
tiensonqin merged 1 commit into
logseq:masterfrom
yuxi-liu-wired:perf/open-code-cache
Oct 7, 2026
Merged

tiensonqin merged 1 commit into
logseq:masterfrom
yuxi-liu-wired:perf/open-code-cache

Conversation

@yuxi-liu-wired

@yuxi-liu-wired yuxi-liu-wired commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

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 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 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 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
tiensonqin force-pushed the perf/open-code-cache branch from fd5efad to 8f87099 Compare October 7, 2026 11:29
@tiensonqin
tiensonqin merged commit 04582c7 into logseq:master Oct 7, 2026
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 13, 2026
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 16, 2026
@yuxi-liu-wired
yuxi-liu-wired deleted the perf/open-code-cache branch October 21, 2026 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants