Skip to content

Avoid quadratic scans in timeline pagination - #7973

Open
cleanunicorn wants to merge 1 commit into
get-bb:mainfrom
cleanunicorn:bb/optimize-project-performance-thr_zqqtx3benw
Open

cleanunicorn wants to merge 1 commit into
get-bb:mainfrom
cleanunicorn:bb/optimize-project-performance-thr_zqqtx3benw

Conversation

@cleanunicorn

@cleanunicorn cleanunicorn commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Human comments

What was wrong

Latest timeline pagination finds older rows that changed inside the window and includes the updates when they fit the byte budget. To calculate which rows still count toward the older-history marker, it searched that update list once per omitted row. When many omitted rows changed, those searches took quadratic time.

What changed

Use the same sequence cutoff in the omitted-row reduction when the updates fit. Each omitted row then takes constant time to classify. When the updates exceed the byte budget, all omitted rows still contribute to the marker. The response shape, update ordering, and byte accounting stay the same.

How you verified

  • Compared the actual paginator from source main and this branch on 100, 500, 1,000, and 1,500 synthetic late updates using Node 24.14.1 on Linux. With 1,500 updates, median pagination time fell from 0.43 ms to 0.14 ms per call. This is a warm-cache microbenchmark of pagination, excluding event selection, projection, and rendering. The issue includes a runnable fixture.
  • Compared full results from both versions at each size with budgets that allow or reject older updates.
  • Server typecheck passed. The full server suite passed with 4,426 tests and 3 skipped. The existing timeline tests cover older-history markers, nested rows, and the shared byte budget.

Fixes #7972

AGENT GENERATED

@cleanunicorn
cleanunicorn marked this pull request as ready for review November 21, 2026 06:03

This branch has not been deployed

No deployments
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.

Avoid quadratic scans when latest timeline pages include older row updates

1 participant