Skip to content

perf: aggregator result-loading speedups (single-scan listing, cached summaries, faster samples parse) - #1376

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/aggregator-profiling
Jul 16, 2026
Merged

Jammy2211 merged 1 commit into
mainfrom
feature/aggregator-profiling

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Summary

Low-hanging performance fruit in aggregator result loading, identified with a new profiling harness (autofit_workspace_test PR to follow) that fabricates mock result directories at scale without running samplers (#1375). At catalogue scale (3000+ results), loading was dominated by redundant directory sweeps, repeated JSON loads and per-row CSV header parsing.

Measured per-result on mock results (idle machine, before/after JSON artefacts in the harness output):

  • values("samples"): 611 → 334 ms at 10k samples (−45%); 68 → 45 ms at 1k samples × 1000 results (−34%); 128 → 93 ms on 15-component models (−28%)
  • AggregateCSV: 110 → 83 ms on 15-component models (−25%); 29 → 22 ms at 1000 results (−24%)
  • repeat from_directory over zipped result trees no longer re-extracts every zip
  • samples_summary/model loads unchanged (~10 ms/result — dominated by JSON→object deserialization, a candidate for follow-up work)

Also documented while profiling: values("samples") across 3000 × 1k-sample results OOMs (~6.6 GB RSS) because every SearchOutput caches its Samples instance — the profiler caps that stage; the scaling limit is left as a known issue for follow-up.

API Changes

None — internal changes only. One behaviour note: Aggregator.from_directory no longer re-extracts a zip whose extracted directory already exists (delete the directory to force re-extraction), and extraction now happens in the same traversal as the metadata scan.
See full details below.

Test Plan

  • pytest test_autofit/ — 1485 passed, 1 skipped
  • New tests (test_autofit/aggregator/test_from_directory.py): zip extract + skip semantics, single-scan suffix listing, samples_summary caching
  • Before/after profiling grids via the autofit_workspace_test harness (profile_*_before_clean.json / profile_*_after_clean.json)
Full API Changes (for automation & release notes)

Changed Behaviour

  • Aggregator.from_directory — zip extraction folded into the scan walk; a zip whose extracted directory already exists is skipped instead of re-extracted every call.
  • SearchOutput.samples_summary / latent_summary / id — now cached per instance (matching the existing model / samples caching).
  • AggregateCSV Row — median-pdf / max-likelihood / latent kwargs cached per row; Row.dict() no longer evaluates each column twice.
  • samples_from_iterator — CSV headers classified and split once instead of per row.

Removed

  • AbstractSearchOutput._outputs / ._outputs_in_directory (private helpers) — replaced by the single-scan _outputs_by_suffix cached property; the public jsons/pickles/arrays/fits properties are unchanged.

Generated by the PyAutoLabs agent workflow.

- from_directory: fold zip extraction into the single scan walk; skip
  zips whose extracted directory already exists (repeat opens no longer
  re-extract every zip)
- SearchOutput: one directory sweep builds the json/pickle/csv/fits
  listings (was 8 rglobs per result via value()); cache
  samples_summary/latent_summary/id per instance
- AggregateCSV: cache per-row kwargs lookups; fix Row.dict() evaluating
  each column twice
- samples_from_iterator: classify + split csv headers once, not per row
  (values("samples") ~30-45% faster)
- tests: from_directory zip semantics, suffix listing, summary caching

Profiled with the new autofit_workspace_test aggregator harness (#1375).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Jammy2211

Copy link
Copy Markdown
Collaborator Author

Workspace harness PR: PyAutoLabs/autofit_workspace_test#48 (merge this library PR first).

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