⚡ Bolt: Optimize planet visibility and computation#349
Conversation
- Hoisted Skyfield `observer.at(check_times)` out of the object iteration loop in `Objects.get_visible` to reuse calculated observer positions. - Consolidated `ephem` and `skyfield` calculation loops in `SolarObjects.compute` to reduce Pandas `iterrows()` overhead. - Cached `Magnitude_float`, `skyfield_object`, `ra_hours`, and `dec_degrees` in `SolarObjects` to accelerate subsequent lookups and filtering. - Moved imports outside of hot paths in `Objects.get_visible`. Co-authored-by: pozar87 <9629954+pozar87@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
- Hoisted Skyfield `observer.at(check_times)` out of the object iteration loop in `Objects.get_visible`. - Consolidated `ephem` and `skyfield` calculation loops in `SolarObjects.compute` to reduce Pandas `iterrows()` overhead. - Cached `Magnitude_float`, `skyfield_object`, `ra_hours`, and `dec_degrees` in `SolarObjects` to accelerate subsequent lookups and filtering. - Implemented `__getstate__` and `__setstate__` in `Objects` to fix pickling failures caused by unpicklable Skyfield objects. - Moved imports outside of hot paths in `Objects.get_visible`. - Switched to cached `get_timescale()` for `Objects` initialization. Co-authored-by: pozar87 <9629954+pozar87@users.noreply.github.com>
💡 What: The optimization implemented
This PR implements two key performance optimizations in the astronomical calculation logic:
observer.at(check_times)call outside of the object iteration loop in theObjects.get_visiblebase class. This ensures that coordinate transformation overhead is paid only once per observation window, rather than for every object.ephemandskyfieldcalculation loops inSolarObjects.computeinto a single pass, significantly reducing Pandasiterrows()overhead.SolarObjectsDataFrame to bypass expensive Pint and Skyfield property access inget_visible.🎯 Why: The performance problem it solves
Redundant coordinate transformations and excessive Pandas iteration were causing unnecessary overhead, particularly noticeable when processing multiple objects or large catalogs. Skyfield's
at(t)is a compute-intensive operation that should be vectorized or hoisted whenever possible.📊 Impact: Expected performance improvement
🔬 Measurement: How to verify the improvement
Run the included profiling script:
python3 scripts/profile_planets.pyThe script measures the time spent in
SolarObjectsinitialization andget_visiblecalls, with detailed cProfile breakdown of internal function overhead.PR created automatically by Jules for task 17197776375071785487 started by @pozar87