Skip to content

perf(threads): index thread lookups by id - #462

Open
Yevanchen wants to merge 1 commit into
mainfrom
perf/threads-lookup-index
Open

perf(threads): index thread lookups by id#462
Yevanchen wants to merge 1 commit into
mainfrom
perf/threads-lookup-index

Conversation

@Yevanchen

Copy link
Copy Markdown
Collaborator

Closes YEF-942

Summary

  • Add a memoized thread id index in the thread query model.
  • Reuse that index for selected-thread lookup and pin/archive/delete action lookups.

Why

  • The complexity optimizer scan flagged repeated thread-route lookup work.
  • This changes repeated thread id lookup from O(n) array scans to O(1) map reads while preserving the sorted thread array used for rendering.

Verification

  • Commands:
    • just fmt-check-path apps/web/src/routes/threads
    • just tc-package @mosoo/web
    • just test-package @mosoo/web
  • Manual steps: N/A
  • Not run: just check because this is a scoped web model change and the web formatting, type-check, and package tests passed.

Impact

  • User/API/contract changes: No contract or visible behavior changes expected.
  • Generated files / GraphQL / DB / lockfile: None.
  • Env or config changes: None.
  • Risk and rollback: Low; rollback restores the previous array lookup path.

Review

  • Closest review areas: apps/web/src/routes/threads/model/use-queries.ts, apps/web/src/routes/threads/model/use-actions.ts, apps/web/src/routes/threads/controller.tsx
  • Known trade-offs: Keeps one O(n) map build per thread-list recompute in exchange for O(1) selected/action lookups.

@Yevanchen
Yevanchen force-pushed the perf/threads-lookup-index branch from bc92ab8 to 4cdf730 Compare July 30, 2026 16:13
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