Skip to content

fix: performance normalization#4

Open
kimlimjustin wants to merge 3 commits intothuasta:mainfrom
kimlimjustin:fix/performance-normalization
Open

fix: performance normalization#4
kimlimjustin wants to merge 3 commits intothuasta:mainfrom
kimlimjustin:fix/performance-normalization

Conversation

@kimlimjustin
Copy link
Contributor

  • Replace per-call JSON disk reads with mtime-based immutable snapshot cache in ProfileStore._read() — callers get the same dict reference instead of a copy.deepcopy clone
  • Add indexed get_todo() that normalizes only the matched item instead of all todos
  • Cache normalized todo list per snapshot version so list_todos() skips re-normalization across 15+ calls per autopilot cycle
  • Skip re-normalizing all 2000 existing audit entries in record_audit() — only normalize the new entry
  • Batch audit lookup in process_supervisor_review_queue() — one scan builds a set, replacing N per-todo 200-entry scans with O(1) membership checks

Replace copy.deepcopy in _read() with an mtime-based immutable snapshot
cache that returns the same dict reference on cache hits, eliminating
O(n) deep copies on every access. Update _write() to refresh the cache
after writes and invalidate the normalized todo cache.

Rename dead-code list_todos to _list_todos_unlocked (fixing missing
method bug) and add a per-snapshot normalized todo cache that avoids
re-normalizing all todos on repeated list_todos calls within the same
snapshot.

Replace _get_todo_unlocked with a direct linear scan that normalizes
only the matched item, avoiding full-list normalization for single
lookups.
Stop calling normalize_audit_entry on every existing audit log entry
when appending a new one. Only the new entry needs normalization;
existing entries were already normalized when they were first recorded.
Reduces record_audit from O(n) normalization passes to O(1).
Replace per-todo audit lookups in process_supervisor_review_queue with
a single batch query that builds a set of already-reviewed todo IDs
upfront. This reduces audit log reads from O(n) per completed todo
to a single O(1) set-membership check, eliminating redundant
list_audit_logs calls in the autopilot loop.
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