Skip to content

Stop paying for the [TILEDBG] diagnostics when debug logging is off - #42

Merged
CSSFrancis merged 1 commit into
mainfrom
fix/tile-diagnostic-cost
Jul 26, 2026
Merged

Stop paying for the [TILEDBG] diagnostics when debug logging is off#42
CSSFrancis merged 1 commit into
mainfrom
fix/tile-diagnostic-cost

Conversation

@CSSFrancis

Copy link
Copy Markdown
Owner

_on_view_changed_internal reported the distinct-value counts of the backend's raw native crop and of the sampled tile. Both are np.unique — full sorts — and both were passed as arguments to _TLOG.debug. Lazy %-formatting does not help there: arguments are evaluated before the call, so every pan and zoom paid for them at any log level.

Measured on a 4096² frame. VIEW_OVERFETCH = 2.0 makes the over-fetched crop the whole image at any zoom below 2×, which is where panning actually happens:

crop cost
np.unique(raw crop) 4096² 259 ms
np.unique(raw crop) 2048² 65 ms
np.unique(raw crop) 1024² 17 ms
np.unique(tile) 1024² 12 ms

End to end, a pan settle on a 4096² frame:

zoom before after
1.1× 378 ms 78 ms
377 ms 81 ms
125 ms 57 ms

The counts are genuinely useful — they catch a backend handing back a downsample instead of native pixels — so they move into _log_fetch_diagnostic behind an isEnabledFor(DEBUG) guard rather than being deleted. _refresh_overview's min/max got the same treatment.

test_tile_diagnostics.py pins the guard rather than the message text, from both sides: no sorting at INFO, the FETCH line still emitted at DEBUG, and the displayed tile byte-identical either way.

Found while chasing slow panning on a 4k in-situ movie in SpyDE. SpyDE needs this released as 0.4.2 before it can bump its anyplotlib>= pin.

Full test_plot2d suite passes (305 + 3 new).

_on_view_changed_internal reported the distinct-value counts of the
backend's raw native crop and of the sampled tile. Both are np.unique --
full sorts -- and both were passed as ARGUMENTS to _TLOG.debug. Lazy
%-formatting does not help there: arguments are evaluated before the call,
so EVERY pan and zoom paid for them at any log level.

Measured on a 4096^2 frame, where VIEW_OVERFETCH=2.0 makes the over-fetched
crop the whole image at any zoom below 2x:

    np.unique(raw crop)  4096^2   259 ms
    np.unique(raw crop)  2048^2    65 ms
    np.unique(tile)      1024^2    12 ms

End to end, a pan settle goes 378 -> 78 ms at 1.1x-2x zoom and 125 -> 57 ms
at 4x. The counts are genuinely useful -- they catch a backend handing back
a downsample instead of native pixels -- so they move into
_log_fetch_diagnostic behind an isEnabledFor(DEBUG) guard rather than being
deleted. _refresh_overview's min/max got the same treatment.

test_tile_diagnostics.py pins the guard (not the message text) from both
sides: no sorting at INFO, the FETCH line still emitted at DEBUG, and the
displayed tile identical either way.
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 66.66667% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.35%. Comparing base (d4755d4) to head (0ebb0ee).

Files with missing lines Patch % Lines
anyplotlib/plot2d/_plot2d.py 66.66% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #42      +/-   ##
==========================================
- Coverage   90.41%   90.35%   -0.07%     
==========================================
  Files          39       39              
  Lines        4008     4014       +6     
==========================================
+ Hits         3624     3627       +3     
- Misses        384      387       +3     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@CSSFrancis
CSSFrancis merged commit 15463d9 into main Jul 26, 2026
12 checks passed
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.

2 participants