Skip to content

[fix] canvas: open node versions without copying every commit - #410

Merged
princepride merged 1 commit into
mainfrom
fix/node-versions-records
Nov 19, 2026
Merged

princepride merged 1 commit into
mainfrom
fix/node-versions-records

Conversation

@princepride

Copy link
Copy Markdown
Collaborator

Summary

  • Opening a node's version history (GET /api/creation/projects/{id}/items/{item}/versions) called history(), which deep-copies every commit snapshot. On a real 500-commit project (108 MB of commit JSON) one open took about 7 s; the listing itself needs well under 0.1 s.
  • node_versions and version_family now scan the shared read-only records(), the same approach version_counts already uses. Only the small listing is deep-copied out, so callers never hold shared records.
  • Applying a version (canvas.applyVersion) goes through version_family too, so it also skips the full copy. The rarer path that restores an edited image document still reads history().

Linked issue

  • No issue applies.

Labels

  • type:bug, area:canvas, area:performance

Test plan

  • Local:
    • pytest tests/test_creation_*.py: 483 passed.
    • New test_listing_scans_shared_records_without_copying_or_exposing_them: fails if history() is called, if a returned object is shared with the commit records, or if the records change. It fails on main and passes with this change.
    • On a copy of a real 500-commit project, compared old and new node_versions for all 9 nodes that have more than one version: identical JSON output, commit records byte-identical before and after. Mean time per call went from 6.83 s to 0.066 s.
  • Left to CI: the full Python and browser suites.

Evidence that it works

  • N/A because: backend-only change with no UI difference. Timings on a live server with the same project, warm cache:
Request Before After
GET .../items/{item}/versions 6.9–7.8 s 0.08–0.13 s

The first request after a server restart still reads all commits from disk (5.9 s here). Opening a project already warms that cache through version-counts.

Provider verification

  • No provider calls were made.

Bilingual UI

  • No user-facing copy changed.

🤖 Generated with Claude Code

Listing a node's versions read history(), which deep-copies every commit
snapshot. On a 500-commit project that took about 7 s per open, while the
listing itself needs well under 0.1 s. Scan the shared read-only records
instead, as version counts already do, and copy only the small listing out
so callers never hold shared records. Applying a version reuses the same
read-only scan.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@princepride princepride added area:canvas Canvas, nodes and direct manipulation area:performance Performance and responsiveness / 性能与响应速度 type:bug Something is broken labels Nov 19, 2026
@princepride
princepride merged commit 7dc1152 into main Nov 19, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:canvas Canvas, nodes and direct manipulation area:performance Performance and responsiveness / 性能与响应速度 type:bug Something is broken

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant