Skip to content

perf(engine): collapse buildTimeline N+1 to one List per event type#62

Merged
tzone85 merged 1 commit into
mainfrom
perf/report-buildtimeline-n+1
Jun 11, 2026
Merged

perf(engine): collapse buildTimeline N+1 to one List per event type#62
tzone85 merged 1 commit into
mainfrom
perf/report-buildtimeline-n+1

Conversation

@tzone85

@tzone85 tzone85 commented Jun 11, 2026

Copy link
Copy Markdown
Owner

Summary

ReportBuilder.buildTimeline iterated five story event types, and inside each ran one rb.es.List call per story id. For a 20-story requirement that's 5 × 20 = 100 sequential queries — 100 JSONL file reads on the default store, 100 SQLite transactions on the SQLiteStore. Report generation on long runs got noticeably slow.

Changes

  • One List per event type with no StoryID filter, then screen results against the existing storyIDSet in memory.
  • 5 queries total regardless of story count.

Test plan

  • New TestReportBuilder_Build_TimelineFiltersByStoryOwnership seeds a STORY_MERGED for a story id outside req-001's set and asserts it does NOT appear in the timeline. Guards the in-memory filter from regressing into "list everything, forget to filter."
  • go build ./..., go vet ./..., go test ./... -count=1 -timeout 240s all green locally.

Audit traceability

Go audit finding GO-MED-9 (2026-06-11 sweep).

ReportBuilder.buildTimeline iterated five story event types, and inside
each ran one rb.es.List call PER story id. For a 20-story requirement
that's 5 × 20 = 100 sequential queries — 100 JSONL file reads on the
default store, 100 SQLite transactions on the SQLiteStore. Report
generation on long runs got noticeably slow.

Switch to one List per event type with no StoryID filter, then screen
results against the existing storyIDSet in memory. 5 queries total
regardless of story count. The filter is cheap: storyIDSet is already
constructed three lines above for the lookup that names each story
title in describeStoryEvent.

New TestReportBuilder_Build_TimelineFiltersByStoryOwnership seeds a
STORY_MERGED for a story id outside req-001's set and asserts it does
NOT appear in the timeline — guards the in-memory filter from
regressing into "list everything, forget to filter."

Surfaced by the 2026-06-11 Go audit (GO-MED-9).
@tzone85 tzone85 merged commit 63c4908 into main Jun 11, 2026
9 of 10 checks passed
@tzone85 tzone85 deleted the perf/report-buildtimeline-n+1 branch June 11, 2026 10:36
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