Skip to content

perf(imagetool): speed up manager refreshes - #517

Draft
kmnhan wants to merge 10 commits into
mainfrom
agent/improve-manager-refresh-performance
Draft

perf(imagetool): speed up manager refreshes#517
kmnhan wants to merge 10 commits into
mainfrom
agent/improve-manager-refresh-performance

Conversation

@kmnhan

@kmnhan kmnhan commented Jul 29, 2026

Copy link
Copy Markdown
Owner

Summary

  • Cache manager tree structure, row lookups, selections, delegate resources, and unchanged Details content.
  • Maintain reverse provenance-dependency and figure UID indexes so status and refresh work targets affected nodes instead of scanning all tools.
  • Preserve Figure Composer gallery items and lazily materialize derivation children rather than rebuilding them on every signal.
  • Coalesce preview, metadata, and dependent-figure refreshes while preserving real-time updates and on-demand Copy Full Code behavior.
  • Keep parsed ScriptInput provenance memoized without allowing runtime cache state to affect Pydantic equality or become stale after model_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 passed
  • Focused changed manager paths with PySide6 — 240 passed
  • Provenance equality and nested file-relinking regressions — 3 passed
  • uv run ruff format .
  • uv run ruff check --fix .
  • uv run mypy src
  • git diff --check

kmnhan added 4 commits July 29, 2026 14:46
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.
@codecov

codecov Bot commented Jul 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.57231% with 52 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.67%. Comparing base (08e0b56) to head (9187b5f).
⚠️ Report is 3 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...rc/erlab/interactive/imagetool/manager/_widgets.py 75.75% 11 Missing and 5 partials ⚠️
.../erlab/interactive/imagetool/manager/_modelview.py 92.44% 9 Missing and 4 partials ⚠️
...rc/erlab/interactive/imagetool/manager/_wrapper.py 92.96% 6 Missing and 3 partials ⚠️
...e/imagetool/manager/_figurecomposer/_collection.py 93.87% 1 Missing and 2 partials ⚠️
src/erlab/interactive/kspace.py 90.00% 2 Missing and 1 partial ⚠️
.../erlab/interactive/imagetool/_provenance/_model.py 95.34% 1 Missing and 1 partial ⚠️
...ab/interactive/imagetool/manager/_details_panel.py 98.36% 0 Missing and 2 partials ⚠️
...erlab/interactive/imagetool/manager/_tool_graph.py 96.96% 0 Missing and 2 partials ⚠️
...rlab/interactive/imagetool/manager/_interaction.py 96.87% 0 Missing and 1 partial ⚠️
...rc/erlab/interactive/imagetool/manager/_lineage.py 91.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #517      +/-   ##
==========================================
+ Coverage   91.65%   91.67%   +0.01%     
==========================================
  Files         247      247              
  Lines       94768    95387     +619     
  Branches    15881    16004     +123     
==========================================
+ Hits        86858    87442     +584     
- Misses       4593     4607      +14     
- Partials     3317     3338      +21     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

kmnhan added 6 commits July 29, 2026 16:20
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.
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.

1 participant