Skip to content

Cache model.parameterization; try interactive matplotlib backends - #1299

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/quick-update-perf
May 27, 2026
Merged

Jammy2211 merged 1 commit into
mainfrom
feature/quick-update-perf

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Summary

Two quick-update performance fixes:

  1. Cache parameterization — AbstractPriorModel.parameterization recursively walks the model tree (14M function calls for 40-Gaussian MGE, ~2.7s). Since the model is immutable during a search, @functools.cached_property reduces subsequent calls from 2.7s to 0.05s per quick update.

  2. Interactive backend fallback in live_viewer.py — the viewer subprocess inherits Agg from the parent (headless PNG rendering). Now tries TkAgg, QtAgg, etc. before giving up, so the live matplotlib window works on systems with a GUI toolkit installed.

API Changes

None — parameterization was already a @property, now @functools.cached_property. Same external interface. The live_viewer backend selection is internal.

Test Plan

  • pytest test_autofit/ — 1412 passed, 1 skipped
  • result_max_lh_info_from drops from 2.1s to 0.05s on second call

🤖 Generated with Claude Code

Two quick-update performance fixes:

1. Cache `AbstractPriorModel.parameterization` via @functools.cached_property.
   For MGE models with 40 Gaussians the recursive tree walk triggers 14M
   function calls (~2.7s). Since the model structure is immutable during a
   search, caching reduces subsequent calls from 2.7s to 0.05s.

2. live_viewer.py: try interactive matplotlib backends (TkAgg, QtAgg, etc.)
   before falling back to the inherited Agg backend. The viewer subprocess
   inherits the parent's Agg (used for headless PNG rendering) but needs a
   GUI backend to display a window.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@Jammy2211 Jammy2211 added the pending-release PR queued for the next release build label May 27, 2026
@Jammy2211
Jammy2211 merged commit f24e915 into main May 27, 2026
11 checks passed
@Jammy2211
Jammy2211 deleted the feature/quick-update-perf branch May 27, 2026 13:40
@Jammy2211 Jammy2211 removed the pending-release PR queued for the next release build label Sep 4, 2026
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