Repository navigation
perf(transform): copy events one level deep in flood and merge_subwatcher_fields - #204
Conversation
…cher_fields Git-Session-Id: bc912f6d-20ed-4a29-b4c4-9e8bdcbb87bb
Review guide (auto-posted)Structured warm-up for reviewers — what changed, what to run, where to look. Key files
Suggested verification
Known risks / watch points
Suggested review focus
Generated by |
[Medium impact] The PR appears safe to merge. SummaryReplaces full event copies with new
Reviews (1) · Last reviewed commit: "perf(transform): copy events one level d..." · Reviewed by Greptile |
|
CI-green and mergeable — waiting only on a maintainer click. This PR is ready to merge, but the bot has pull-only access to this repo and can't self-merge — surfacing it here so it isn't lost. The monitoring loop will stop re-flagging it now that this note is posted. |
🤖 AI code reviewIn Safe to merge — no P0/P1 findingsConfidence 5/5 ✅ No findings. The diff looks correct to me on this pass. Files changed (4) — the diff as I read it
Reviewed Maintainer commands
|
Follow-up to #203, which removed the deepcopy in
filter_period_intersectfor the year-query slowdown (ActivityWatch/activitywatch#1545). Two deepcopy hot spots remain on master.Change
flood(): replacedeepcopy(events)of the whole list with newEvents and adict(data)copy. flood only reassignstimestamp/duration; it never mutatesdatain place.merge_subwatcher_fields(): the per-eventdeepcopy(base)calls become the same one-level copy (_copy_event). The code only assigns top-leveldatakeys. Values injected from subwatcher events are stilldeepcopyd, so injected nested values stay isolated.datadict are now shared with the input (as in perf(transform): copy events one level deep in filter_period_intersect #203); none of these transforms mutate them.Measurement
Synthetic, same interpreter, median of 3 (not the activitywatch year-query harness, which needs built server binaries):
flood(), 150k eventsmerge_subwatcher_fields, 4k base × 1.5k submerge_subwatcher_fieldsis dominated by its per-base scan of subwatcher events, so the copy change is a small win there;flood()halves.Tests
Full suite: 496 passed, 5 skipped. Added two isolation tests (input events and their
datauntouched, outputs are distinct objects). They also pass on the old deepcopy code (it isolated fully), so they guard the behaviour rather than prove the speedup.Note
#202 also edits
flood.py(adjacent hunk near the sort line); whichever lands second needs a trivial rebase.