perf(server): avoid thread-wide scans for message projection#1647
perf(server): avoid thread-wide scans for message projection#1647juliusmarminge merged 2 commits intomainfrom
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
0e0bad4 to
dbbf25c
Compare
f07a69d to
ed2220e
Compare
ApprovabilityVerdict: Approved Performance optimization that replaces a thread-wide message scan with a direct message ID lookup. The business logic is preserved and restructured using Effect's Option utilities. The PR author owns this code and tests are included. You can customize Macroscope's approvability policy. Learn more. |
ed2220e to
acc331e
Compare
dbbf25c to
03d24d6
Compare
acc331e to
f23d141
Compare
Dismissing prior approval to re-evaluate f23d141
Co-authored-by: codex <codex@users.noreply.github.com>
f23d141 to
059ff5b
Compare
Co-authored-by: codex <codex@users.noreply.github.com>
Dismissing prior approval to re-evaluate d64edba
…gg#1647) Co-authored-by: codex <codex@users.noreply.github.com>
…gg#1647) Co-authored-by: codex <codex@users.noreply.github.com>
Summary
thread.message-sentprojection updateStack
codex/backend-perf-queries)Validation
bun run test src/persistence/Layers/ProjectionThreadMessages.test.ts src/orchestration/Layers/ProjectionPipeline.test.tsbun run test src/orchestration/Layers/ProjectionSnapshotQuery.test.ts src/checkpointing/Layers/CheckpointDiffQuery.test.ts src/persistence/Layers/ProjectionThreadMessages.test.ts src/orchestration/Layers/ProjectionPipeline.test.ts src/orchestration/Layers/OrchestrationEngine.test.ts src/orchestration/Layers/CheckpointReactor.test.ts src/orchestration/Layers/ProviderRuntimeIngestion.test.ts src/orchestration/Layers/ProviderCommandReactor.test.tsbun fmtbun lintbun typecheck(currently fails inapps/webdue pre-existing@effect/atom-react/Layer.suspenderrors)Note
Medium Risk
Changes the
thread.message-sentprojection write path to depend on a newgetByMessageIdquery instead of scanning all messages in a thread, which could subtly affect message text/attachment merge behavior if the lookup or Option handling is incorrect.Overview
Improves message projection performance by avoiding per-event thread-wide reads when handling
thread.message-sent.Adds a keyed
ProjectionThreadMessageRepository.getByMessageIdAPI (service + SQLite implementation) and refactors the projector to fetch only the prior row for that message to compute streaming text updates and attachment retention/clearing. Tests are extended to cover the new lookup path alongside existing attachment-preservation behavior.Written by Cursor Bugbot for commit d64edba. This will update automatically on new commits. Configure here.
Note
Replace thread-wide message scan with direct lookup by messageId in projection pipeline
getByMessageIdtoProjectionThreadMessageRepository(ProjectionThreadMessages.ts), returningOption<ProjectionThreadMessage>via a targeted SQL query instead of listing all thread messages.thread.message-senthandler in ProjectionPipeline.ts to use this new lookup, eliminating a full thread scan per message event.toProjectionThreadMessagehelper to consolidate row-to-domain mapping used by bothlistByThreadIdandgetByMessageId.Macroscope summarized d64edba.