Skip to content

perf(db): flush block trees before resources - #13437

Merged
tiensonqin merged 1 commit into
logseq:masterfrom
yuxi-liu-wired:perf/snapshot-order
Sep 30, 2026
Merged

tiensonqin merged 1 commit into
logseq:masterfrom
yuxi-liu-wired:perf/snapshot-order

Conversation

@yuxi-liu-wired

@yuxi-liu-wired yuxi-liu-wired commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

What changes

subs-loader now sends the render-snapshot requests for blocks and children before the other resources. View resources (:view-data, :views) still leave first and alone. On a page open, the page's children (the body) no longer wait behind the title's reactions, comment threads, display properties and favorite status, or behind the linked references' blocks and breadcrumbs. On an imported graph of about 150k blocks, a cold open of a page that is not a tag showed its first screen of blocks 100-446 ms earlier (medians per page, 9 pages of 9 to 742 blocks); pages of 9-21 blocks went from 415-436 ms to 111-219 ms.

Mechanism

Since #13226, subs-loader keeps one get-render-snapshots request in flight and picks each request by kind in the order [:view-resources :resources :blocks :children] (flush-kind-order). Components ask for data as they render, so every answer queues more requests: the page block's answer mounts the title, the body and the references at once, and their requests land in the same batch. The body's [:children page-uuid] then waits until no resource is pending. On cold opens of 3 pages (13, 92 and 742 blocks) that request left at 208-485 ms, after 11 other snapshot requests: the page identity, favorite status, the page block, the title's decorations, the linked references' view, view data, blocks and breadcrumb, and the rows' decorations. On the 92-block page the title's decorations request alone took 257 ms in the worker.

The order is now [:view-resources :blocks :children :resources]. The view-resource group is unchanged, so a tag page's first-window :view-data request still leaves in its own request ahead of any block or children request (the reason #13226 split it out). The request limits per kind and the single request in flight are unchanged. Resources now wait until the queued blocks and children are sent, so the title's decorations and the rows' reactions, comment threads and display properties arrive after the rows; during a burst of block requests (a long scroll) they wait for the burst.

Numbers

Desktop release builds of master (d9d625847) and of this branch, each shipped as only the renderer bundle in the same nightly app shell, on the same imported graph (3240 pages, about 154k blocks). Pages sampled across the graph's size range; each run relaunches the app per page, then opens the page cold and twice warm. The builds alternate run by run, 3 runs per build. Medians in ms from navigation to the frame in which the first screen of the page's blocks is in the DOM:

page cold, master cold, this branch warm, master warm, this branch
9 blocks 415 111 65 80
13 blocks 436 150 90 95
21 blocks 423 219 105 123
journal day, 19 blocks 406 213 99 110
65 blocks 489 389 203 231
92 blocks 838 392 240 248
126 blocks 620 277 136 147
389 blocks 649 489 160 220
742 blocks 582 456 248 231
tag with 2 objects, 67 blocks 1192 1237 945 942
tag with 2 objects, 1286 blocks 1240 1155 951 965

The page's children request moved from 208-485 ms to 45-70 ms, now after only the page identity and the page block. Tag pages do not change, since their body waits for the 800 ms timer of #13226 (#13435 replaces that timer). Warm opens send the same requests in the same order on both builds, and none of them is a block or children request (the renderer's cache holds them), so the ordering does not act on them. The warm medians differ by -17 to +60 ms, and 3 runs do not separate those differences from the spread between launches: in a separate logged run, master took 111 ms on the third open of the 21-block page (64-76 ms in the timed runs) and 237 ms on the warm open of the 389-block page (159-214 ms), inside this branch's ranges.

Request logs of 5 tags (2 to 2686 objects), each opened cold and twice warm, on master, on this branch, and on this branch combined with #13435: in all 15 opens per build the first-window :view-data request carried only that resource and no body request (children, bidirectional properties, page membership, linked references) left before it.

Tests

  • frontend.db.subs-loader-test: request-groups-flushes-block-trees-before-resources-test (renamed from request-groups-flushes-resources-before-block-trees-test) now expects the groups view resources, blocks, children, other resources, and keeps the check that block-ref-count does not share the first table window request.
  • frontend.db.subs-loader-test, frontend.db.subs-test, frontend.components.page-first-paint-test, frontend.components.page-test, frontend.components.views-test: 0 failures, run with TZ=Etc/GMT+12 and TZ=Pacific/Kiritimati.
  • The whole unit suite, once with TZ=Etc/GMT+12 and once with TZ=Pacific/Kiritimati: 2476 tests, 12407 assertions each. The only failures are the 3 zone-dependent tests that fix(test): build test dates in local time #13430 fixes (6 assertions at UTC-12, 4 at UTC+14), the same as on master.
  • clj-kondo on the 2 changed files: 0 errors, 0 warnings.

Allow edits from maintainers.


Devin Review

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

subs-loader sends one render-snapshot request at a time and picked
each request by kind in the order view resources, resources, blocks,
children. On a page open the page's children request (open-block-tree,
the body) was queued behind the title's reactions, comment threads,
display properties and favorite status, and behind the linked
references' blocks and breadcrumbs, so it left after about 12 serial
requests.

Flush blocks and children before other resources. View resources
(view-data, views) still leave first and alone, so a tag page's
first table window keeps its own request ahead of everything else.
@tiensonqin
tiensonqin merged commit 8f59f69 into logseq:master Sep 30, 2026
10 of 11 checks passed
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Sep 30, 2026
logseq#13545, logseq#13546 and logseq#13547 replace the 9 open pull requests they bundle;
logseq#13468, logseq#13437, logseq#13475 and logseq#13528 are in upstream master.
@yuxi-liu-wired
yuxi-liu-wired deleted the perf/snapshot-order branch September 30, 2026 20:03
devin-ai-integration Bot pushed a commit that referenced this pull request Oct 1, 2026
subs-loader sends one render-snapshot request at a time and picked
each request by kind in the order view resources, resources, blocks,
children. On a page open the page's children request (open-block-tree,
the body) was queued behind the title's reactions, comment threads,
display properties and favorite status, and behind the linked
references' blocks and breadcrumbs, so it left after about 12 serial
requests.

Flush blocks and children before other resources. View resources
(view-data, views) still leave first and alone, so a tag page's
first table window keeps its own request ahead of everything else.
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 1, 2026
logseq#13545, logseq#13546 and logseq#13547 replace the 9 open pull requests they bundle;
logseq#13468, logseq#13437, logseq#13475 and logseq#13528 are in upstream master.
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 4, 2026
logseq#13545, logseq#13546 and logseq#13547 replace the 9 open pull requests they bundle;
logseq#13468, logseq#13437, logseq#13475 and logseq#13528 are in upstream master.
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 8, 2026
logseq#13545, logseq#13546 and logseq#13547 replace the 9 open pull requests they bundle;
logseq#13468, logseq#13437, logseq#13475 and logseq#13528 are in upstream master.
devin-ai-integration Bot pushed a commit that referenced this pull request Oct 8, 2026
subs-loader sends one render-snapshot request at a time and picked
each request by kind in the order view resources, resources, blocks,
children. On a page open the page's children request (open-block-tree,
the body) was queued behind the title's reactions, comment threads,
display properties and favorite status, and behind the linked
references' blocks and breadcrumbs, so it left after about 12 serial
requests.

Flush blocks and children before other resources. View resources
(view-data, views) still leave first and alone, so a tag page's
first table window keeps its own request ahead of everything else.
devin-ai-integration Bot pushed a commit that referenced this pull request Oct 8, 2026
subs-loader sends one render-snapshot request at a time and picked
each request by kind in the order view resources, resources, blocks,
children. On a page open the page's children request (open-block-tree,
the body) was queued behind the title's reactions, comment threads,
display properties and favorite status, and behind the linked
references' blocks and breadcrumbs, so it left after about 12 serial
requests.

Flush blocks and children before other resources. View resources
(view-data, views) still leave first and alone, so a tag page's
first table window keeps its own request ahead of everything else.
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 11, 2026
logseq#13545, logseq#13546 and logseq#13547 replace the 9 open pull requests they bundle;
logseq#13468, logseq#13437, logseq#13475 and logseq#13528 are in upstream master.
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 13, 2026
logseq#13545, logseq#13546 and logseq#13547 replace the 9 open pull requests they bundle;
logseq#13468, logseq#13437, logseq#13475 and logseq#13528 are in upstream master.
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 16, 2026
logseq#13545, logseq#13546 and logseq#13547 replace the 9 open pull requests they bundle;
logseq#13468, logseq#13437, logseq#13475 and logseq#13528 are in upstream master.
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