perf(imagetool): speed up manager refreshes - #517
Draft
kmnhan wants to merge 10 commits into
Draft
Conversation
Cache passive tool provenance and load nested derivation rows only when needed. Coalesce selected-row updates and reuse KTool energy slices. Preserve pending note edits during delayed refreshes.
Refresh derivation and dependency caches when a full provenance result replaces a passive result. Keep idle work queued until managed mouse interactions finish, including timer-driven spin-box repeats.
Treat a double-click event as the second mouse press. Keep idle work blocked across managed-window focus changes, and release the block only when Qt reports a release or cancels the mouse grab. Add regression tests for double-clicks, outside releases, cancellation, and multiple buttons.
Validate cached selections against graph structure changes. Track derivation cache revisions across watched bindings and source lineages, including live ImageTool filters. Refresh only the selected details lineage when provenance changes.
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
ScriptInputprovenance memoized without allowing runtime cache state to affect Pydantic equality or become stale aftermodel_copy.Problem
Manager callbacks repeatedly rebuilt complete provenance histories, scanned every node for dependencies, recreated Qt items and paint resources, and recalculated selection mappings. These costs accumulated across frequent signals and grew with the number of tools and derivation rows.
Result
Repeated refreshes for unchanged tools are now independent of derivation-history length. Structural work is generation-cached, dependency work follows a reverse index, and expensive derivation children are built only when expanded. First display and genuine structure or provenance changes still materialize the rows needed by the UI.
Copy Full Code continues to compile complete deferred provenance only when the user requests it.
Validation
QT_QPA_PLATFORM=offscreen uv run --group pyqt6 pytest -q tests/interactive/imagetool/manager --maxfail=1— 1,927 passeduv run ruff format .uv run ruff check --fix .uv run mypy srcgit diff --check