Skip to content

Cache tracing of footprint outlines - #209

Open
nemovc wants to merge 1 commit into
lsst:mainfrom
nemovc:cache-footprint-outline-tracing
Open

Cache tracing of footprint outlines#209
nemovc wants to merge 1 commit into
lsst:mainfrom
nemovc:cache-footprint-outline-tracing

Conversation

@nemovc

@nemovc nemovc commented Aug 26, 2026

Copy link
Copy Markdown

Tracing region outlines out of a HEALPix footprint takes a couple of seconds, and is repeated in full every time a map is built, even though a process may build many maps from one shared footprint.

Split the tracing into _trace_footprint_outlines, cached on the contents of the footprint. The footprint is keyed as bytes because an ndarray is unhashable, and so cannot be an argument to a cached function; the round trip through bytes costs a fraction of a millisecond against the seconds it saves. _compute_footprint_outlines returns a copy, so that a caller that modifies the outlines it gets back cannot corrupt the cached value.

@ehneilsen
ehneilsen self-requested a review August 26, 2026 17:21
Tracing region outlines out of a HEALPix footprint takes a couple of
seconds, and is repeated in full every time a map is built, even though
a process may build many maps from one shared footprint.

Split the tracing into _trace_footprint_outlines, cached on the contents
of the footprint. The footprint is keyed as bytes because an ndarray is
unhashable, and so cannot be an argument to a cached function; the round
trip through bytes costs a fraction of a millisecond against the seconds
it saves. _compute_footprint_outlines returns a copy, so that a caller
that modifies the outlines it gets back cannot corrupt the cached value.
@nemovc
nemovc force-pushed the cache-footprint-outline-tracing branch from 21ca212 to cf66158 Compare September 3, 2026 01:45
@codecov

codecov Bot commented Sep 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.73418% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 71.94%. Comparing base (f1d7f82) to head (cf66158).
⚠️ Report is 758 commits behind head on main.

Files with missing lines Patch % Lines
tests/test_plot_visit_skymaps.py 98.59% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #209      +/-   ##
==========================================
+ Coverage   67.49%   71.94%   +4.45%     
==========================================
  Files          54      147      +93     
  Lines        4104    10388    +6284     
  Branches      576     1115     +539     
==========================================
+ Hits         2770     7474    +4704     
- Misses       1097     2416    +1319     
- Partials      237      498     +261     

☔ 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.

footprint_outline = footprint_outline.drop(tiny_loops)
return footprint_outline

@staticmethod

@ehneilsen ehneilsen Sep 3, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is being really picky and more about best practices than something I actually think makes a difference here, but this should probably be a class method rather that a static method, and then you can use the passed class instead of VisitMapBuilder by name. That way, subclasses can replace _trace_footprint_outlines if they need to.

@ehneilsen ehneilsen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's one minor suggestion (in a comment), but I don't think it's important enough to block merging.

@rhiannonlynne

Copy link
Copy Markdown
Member

@nemovc you are cleared to merge this PR, unless you want to address Eric's comment above about @staticmethod vs. class method.

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.

3 participants