Skip to content

perf: build the real-Moon centerline once per real eclipse in fixed_system_search#7

Merged
wiyth00 merged 2 commits into
mainfrom
perf/hoist-real-moon-track
Jul 25, 2026
Merged

perf: build the real-Moon centerline once per real eclipse in fixed_system_search#7
wiyth00 merged 2 commits into
mainfrom
perf/hoist-real-moon-track

Conversation

@wiyth00

@wiyth00 wiyth00 commented Jul 25, 2026

Copy link
Copy Markdown
Owner

Summary

In fixed_system_search, generate_central_track(context, real_tt, "real_moon", step_seconds=120.0, include_partial_maximum=True) sat inside the for second_event in second_events: loop. Its only time-dependent argument is real_tt, which is fixed for the whole loop, so the identical track was recomputed for every second-moon candidate of the same real eclipse.

  • Hoist the real-Moon generate_central_track call above the inner loop
  • Add if not second_events: continue first, so real eclipses with no candidates do less work than before rather than more (without this guard, hoisting would build a track for every real eclipse in the window, including the ones that currently build none)

Work plan item P1 / 4.

Note on aliasing

Candidates from the same real eclipse now share one real_track dict rather than each holding an equal-valued copy, including the entries stored in tracks[event.event_id]. Every downstream consumer (minimum_track_distance_km, _best_common_location, plotting) reads without mutating, so this is safe — but it is the one behavioural difference worth a reviewer's eye.

Scientific impact

None. The hoisted call is argument-for-argument identical to the one it replaces, and generate_central_track is a pure function of (context, tt_jd, body, step_seconds, include_partial_maximum). Track distances, classifications, and site selection are bit-for-bit unchanged.

Suggested verification per the work plan: run the fixed-system search over a 1-year window and diff all_candidates.csv before/after — it should be byte-identical.

  • No change to computed results
  • Results change (described above)

Checklist

  • ruff check . passes
  • pytest passes locally
  • New or changed behaviour is covered by a test
  • Docs / README updated if user-facing behaviour changed

tests/test_fixed_system_search_track_reuse.py stubs the search's collaborators so it needs no ephemeris kernel, and asserts one real_moon build against three second_moon builds. It fails on main (3 real-Moon builds) and passes here. A second case asserts no track is built when a real eclipse yields no candidates.

Lint/test boxes left unchecked because this branch was pushed without a local run — CI on this PR is the first execution.

wiyth00 added 2 commits July 25, 2026 10:56
generate_central_track(context, real_tt, "real_moon", ...) depends only on
real_tt, but was called once per second-moon candidate inside the inner loop
of fixed_system_search. Hoist it above the loop.

Results are unchanged: the hoisted call takes identical arguments and the
track is treated as read-only downstream.
Fails on main, where generate_central_track is called once per second-moon
candidate instead of once per real eclipse.
@wiyth00
wiyth00 merged commit 2f2368e into main Jul 25, 2026
1 check 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.

1 participant