diff --git a/.jules/bolt.md b/.jules/bolt.md new file mode 100644 index 00000000..cd8014ed --- /dev/null +++ b/.jules/bolt.md @@ -0,0 +1,4 @@ + +## 2026-05-19 - Defer dictionary allocation in orbital pass loop +**Learning:** Generating dictionaries and formatting datetime strings in a tight loop where the result is immediately discarded for >90% of iterations creates a massive, unnecessary performance bottleneck. +**Action:** Always defer expensive object allocations and string formatting operations until *after* filtering conditions (like visibility checks) have passed. diff --git a/backend/api/routers/orbital.py b/backend/api/routers/orbital.py index 73b34753..4c73d20b 100644 --- a/backend/api/routers/orbital.py +++ b/backend/api/routers/orbital.py @@ -187,14 +187,15 @@ async def get_passes( r_ecef = teme_to_ecef(r, jd, fr) az, el, rng = ecef_to_topocentric(obs_ecef, r_ecef, lat, lon) - point = { - "t": t.strftime("%Y-%m-%dT%H:%M:%SZ"), - "az": round(az, 2), - "el": round(el, 2), - "slant_range_km": round(rng, 3), - } - if el >= min_elevation: + # Defer string formatting and allocation until we know satellite is visible + point = { + "t": t.strftime("%Y-%m-%dT%H:%M:%SZ"), + "az": round(az, 2), + "el": round(el, 2), + "slant_range_km": round(rng, 3), + } + if not in_pass: in_pass = True current_pass_points = []