You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
perf: cache prior-config lookups (from_dict model deserialization floor) #129
Follow-up authorized off the aggregator profiling arc (PyAutoFit#1375/#1385): the recorded "deeper, not low-hanging" target. cProfile of values("samples_summary") over 100 mock results (12ms/result): 77% is the model load, and most of that is Model.__init__ building default priors from prior config — JSONPriorConfig.path_value_tuples re-sorts the entire flattened config dict on every lookup (the flattened map is cached, the sort is not), and __call__ then linear-scans it, with identical (class, attribute) queries repeating for every prior of every result.
Plan
autoconf/json_prior/config.py: cache the sorted path_value_tuples on the instance; memoize __call__ and for_class_and_suffix_path per instance (positive results and KeyError misses — the class-family probe relies on expected misses). Instance-level caches are invalidated naturally: config pushes construct fresh JSONPriorConfig instances, and returned sub-dicts were already aliased across calls today, so no new sharing is introduced.
Measure with the merged aggregator harness (summary/model stages, before/after) + cProfile.
Suites: autoconf + full PyAutoFit (prior config is load-bearing everywhere).
Worktree:~/Code/PyAutoLabs-wt/prior-config-cache/ · Branch:feature/prior-config-cache · Repos: PyAutoConf (only; autofit_workspace_test used read-only for measurement).
Measured (aggregator harness, like-for-like load): values("model")8.15 → 4.60 ms/result (−44%), values("samples_summary") 8.73 → 6.58 (−25%). The two defects: the flattened config was re-sorted on every lookup, and identical queries linear-scanned it repeatedly. Both cached per instance; benefits every Model/Collection construction including search startup.
What remains of the deserialization floor after this: the sample-json from_dict and prior-object construction itself (~4.6 ms/result) — diminishing returns from here; not pursuing further. Closing.
Activity
Jammy2211 commentedon Jul 17, 2026
Shipped and merged (2026-07-17): #130.
Measured (aggregator harness, like-for-like load):
values("model")8.15 → 4.60 ms/result (−44%),values("samples_summary")8.73 → 6.58 (−25%). The two defects: the flattened config was re-sorted on every lookup, and identical queries linear-scanned it repeatedly. Both cached per instance; benefits every Model/Collection construction including search startup.What remains of the deserialization floor after this: the sample-json
from_dictand prior-object construction itself (~4.6 ms/result) — diminishing returns from here; not pursuing further. Closing.