Skip to content

perf: profile + speed up AggregateImages/AggregateFITS (png/fits workflow aggregators) #1385

Closed

Description

@Jammy2211

Overview

Final leg of the aggregator profiling arc (#1375 A–D + awt#171 merged): only AggregateCSV of the three catalogue workflow aggregators was profiled and sped up (−25% in #1376). AggregateImages (png_make) and AggregateFITS (fits_make) were never measured — and code reading already shows AggregateFITS._hdus re-opens the same fits file once per requested HDU via result.value(...) (an uncached fits.open per HDU) and never closes handles.

Plan

  • Harness (autofit_workspace_test): give mock templates realistic payloads — a panelled subplot_fit.png and a multi-HDU fit.fits — and add aggregate_images (output_to_folder, the png_make pattern) + aggregate_fits (extract_fits + output_to_folder, the fits_make pattern) stages to the profiling grid.
  • Baseline, then low-hanging fruit in autofit/aggregator/summary/aggregate_images.py / aggregate_fits.py (candidates: one fits.open per source file per result; close handles; avoid repeated result.value lookups). Behaviour-preserving; before/after in the PR.
  • Out of scope: faster single-file deserialization (known deeper follow-up).

Worktree: ~/Code/PyAutoLabs-wt/aggregate-images-fits/ · Branch: feature/aggregate-images-fits · Repos: PyAutoFit (primary), autofit_workspace_test — both clean on main, unclaimed.

Activity

  1. Jammy2211 commented on Jul 17, 2026

    @Jammy2211
    CollaboratorAuthor

    Shipped and merged (2026-07-17): #1386 + PyAutoLabs/autofit_workspace_test#51.

    What the png/fits profiling found:

    • AggregateImages (png_make): ~1.5 ms/result, already caches one open per subplot type per result — profiled clean, no fruit taken.
    • AggregateFITS (fits_make): leaked one file handle per requested HDU per result (200 fds measured at 100 results × 2 HDUs). At the default ulimit of 1024, extract_fits/output_to_folder crashes with "Too many open files" around ~500 results — the 3000-lens Euclid catalogue would have hit this. extract_csv leaked one handle per result the same way.
    • Fixed: one open per source file per result, data copied out of the memmap, deterministic close. 0 leaked fds at 100 results, identical output, 19% faster at 2 HDUs (interleaved A/B; grows with HDU count — the workflow guide uses 4).

    This closes the aggregator arc's last uncovered leg: all three catalogue workflows (csv −25% in #1376, png profiled-clean, fits leak-fixed +19%) are now measured and harnessed. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions