Repository navigation
perf(startup): build the LRU caches empty - #13632
Merged
Merged
Conversation
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Oct 6, 2026
yuxi-liu-wired
force-pushed
the
perf/open-cache
branch
from
October 6, 2026 17:40
ded8aec to
20bc356
Compare
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Oct 6, 2026
tiensonqin
approved these changes
Oct 7, 2026
`frontend.db.subs` creates its warm block cache, and `frontend.format.block` its block parse cache, with `cljs.cache/lru-cache-factory` at load, with thresholds of 20000 and 5000. The factory seeds the cache's eviction queue with one placeholder entry per slot, in a priority map, before anything is cached; in CPU profiles of a desktop window reload `cljs.cache/build-leastness-queue` took about 120 ms (warm cache) and about 90 ms (parse cache) of the renderer's time before the home screen, and the warm cache's again whenever the store is reset for another graph. Both caches are now built empty, by a new `frontend.common.cache/empty-lru` (`cache/->LRUCache` with an empty queue). `LRUCache` evicts by the queue's real size (`miss` evicts once it holds `limit` entries), so an empty cache holds, hits and evicts the same entries. New test `empty-lru-evicts-as-the-factory-cache-test` in `src/test/frontend/db/subs_test.cljs`: the same misses, hits and evictions on an `empty-lru` and on a factory cache of the same size leave the same entries. `frontend.db.subs-test` and `frontend.format.block-test` pass.
tiensonqin
force-pushed
the
perf/open-cache
branch
from
October 7, 2026 11:37
20bc356 to
0ed034d
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
`frontend.db.subs` creates its warm block cache, and `frontend.format.block` its block parse cache, with `cljs.cache/lru-cache-factory` at load, with thresholds of 20000 and 5000. The factory seeds the cache's eviction queue with one placeholder entry per slot, in a priority map, before anything is cached; in CPU profiles of a desktop window reload `cljs.cache/build-leastness-queue` took about 120 ms (warm cache) and about 90 ms (parse cache) of the renderer's time before the home screen, and the warm cache's again whenever the store is reset for another graph. Both caches are now built empty, by a new `frontend.common.cache/empty-lru` (`cache/->LRUCache` with an empty queue). `LRUCache` evicts by the queue's real size (`miss` evicts once it holds `limit` entries), so an empty cache holds, hits and evicts the same entries. New test `empty-lru-evicts-as-the-factory-cache-test` in `src/test/frontend/db/subs_test.cljs`: the same misses, hits and evictions on an `empty-lru` and on a factory cache of the same size leave the same entries. `frontend.db.subs-test` and `frontend.format.block-test` pass.
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.
frontend.db.subscreates its warm block cache, andfrontend.format.blockits block parse cache, withcljs.cache/lru-cache-factoryat load, with thresholds of 20000 and 5000. The factory seeds the cache's eviction queue with one placeholder entry per slot, in a priority map, before anything is cached; in CPU profiles of a desktop window reloadcljs.cache/build-leastness-queuetook about 120 ms (warm cache) and about 90 ms (parse cache) of the renderer's time before the home screen, and the warm cache's again whenever the store is reset for another graph.Both caches are now built empty, by a new
frontend.common.cache/empty-lru(cache/->LRUCachewith an empty queue).LRUCacheevicts by the queue's real size (missevicts once it holdslimitentries), so an empty cache holds, hits and evicts the same entries.New test
empty-lru-evicts-as-the-factory-cache-testinsrc/test/frontend/db/subs_test.cljs: the same misses, hits and evictions on anempty-lruand on a factory cache of the same size leave the same entries.frontend.db.subs-testandfrontend.format.block-testpass.