mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-14 22:50:51 +00:00
perf(insights): compute-once feature snapshot per warm scope
The comprehensive briefing's bounded feature read (extractFeatures) was paid more than once where it should not be: the on-demand route and the shared generator each run a downgrade ladder that re-reads with identical arguments, and a nightly warm has no shared object across consumers in a single tick. Add a request/run-scoped feature cache: withFeatureCacheScope opens an AsyncLocalStorage store, getCachedFeatures memoises the first compute per (userId, day, includeRaw, sinceDays), gated on a cheap salient-input fingerprint so a mid-scope ingest recomputes and a probe failure fails safe. Outside a scope it is a pure passthrough. Wired into the comprehensive generator, the on-demand POST handler, and the nightly per-candidate loop + forceWarmUser. Coach keeps its own snapshot.
This commit is contained in:
1 parent
7f9aeba918
commit
d7c71f3b32
5 files changed
+1257
-784
No files matched your search
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user