Repository navigation
[perf] canvas: isolate published project reads and prevent history GIL starvation during canvas open and switch - #562
Merged
FayeSpica merged 3 commits intoNov 29, 2026
Conversation
…L starvation Signed-off-by: Weiming Liao <liaowm5@gmail.com>
… deadlock Signed-off-by: Weiming Liao <liaowm5@gmail.com>
FayeSpica
marked this pull request as ready for review
November 29, 2026 01:06
FayeSpica
requested review from
hsliuustc0106 and
princepride
as code owners
November 29, 2026 01:06
## summary Resolve tool task queries from the published project head and cover polling while a background commit holds the publication lock.
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.
Summary
Opening or switching between large projects with long commit histories previously hit 12 s timeouts and
409 storage_busyerrors. This PR keeps published project reads isolated from unrelated catalog-lock writers, stops background history endpoints from starving the Python GIL, and defers non-essential canvas startup reads.GET /api/creation/projects?navigation=true) without holding the global catalog lock across unrelated reads, while preserving editing leases, locks, and atomic publication.GET /api/creation/projects/{id}/canvas-texts) and reference evidence checks (GET /api/creation/projects/{id}/reference-evidence) until after initial canvas structure renders, and skip the redundantmodel_copy(deep=True)on read-onlyPOST /open-canvasresponses.reference_catalog,_inventory,asset_list,_usage_many,versions) fromhistory()deep copies to shared immutablerecords(), and resolve the project directory once perreference_catalogcall with a singlesnapshot_media_reader.RECORD_CACHE_BYTESfrom 512 MiB to 1 GiB to stop LRU thrashing on 500+ MB commit chains, parse records directly withCommitRecord.model_validate_json, coalesce concurrent cold_read_historycalls per(path, head)(joining in-flight warms), and yield the GIL briefly during uncached history walks so Uvicorn keeps serving foreground requests.useProjectMentionAssetslazily when a node composer opens instead of on every canvas open or switch, and throttlereference-catalogthroughBACKGROUND_PROJECT_READ.Linked issue
Relates to #153.
Fixes #NorRefs #Nis included, or no issue appliesLabels
type:bug(ortype:perf) andarea:canvasTest plan
pytest -q tests/test_creation_history_service.py tests/test_creation_storage.py tests/test_creation_node_versions.py tests/test_creation_api.pynode --test tests/backendWorkspace.test.ts tests/creationClient.test.tsnpm run build && npm run check:i18ndocs/development/ui-performance.md.Test result
test_reference_catalog_checks_files_against_its_one_snapshotthatreference_catalogperforms zerohistory()deep copies and resolves_published_manifestonce across multiple assets).npm run buildpassed;npm run check:i18npassed with 3,413 keys and 0 problems.reference-catalognot requested on load): median 0.82 s, P90 0.92 s (range 0.81 s–0.92 s).409responses; 10 measured switches): first feedback median 0.02 s, P90 0.03 s (budget P90 ≤ 0.10 s); usable ready median 0.51 s, P90 0.63 s (166-node: 0.44 s–0.50 s, 71-node: 0.51 s–0.63 s; budget median ≤ 0.50 s, P90 ≤ 1.00 s).Remaining gaps before marking ready for review: warm-switch usable-ready median (0.51 s) is 0.01 s above the 0.50 s reference target on this 697-commit fixture; full CI and nightly browser lanes have not yet run on this branch.
Evidence that it works
Verified by the unit/service regressions and isolated Playwright Chromium latency runs recorded in Test result above.
Provider verification
All tests and browser checks ran against local project fixtures without calling any model provider.
Bilingual UI
No user-facing copy changed;
npm run check:i18npassed with 0 problems.