Skip to content

fast timeline - #210

Open
jtoman wants to merge 1 commit into
masterfrom
jtoman/fast-timeline
Open

fast timeline#210
jtoman wants to merge 1 commit into
masterfrom
jtoman/fast-timeline

Conversation

@jtoman

@jtoman jtoman commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Adds a heuristic version of timeline loading which is, in practice, at least an order of magnitude faster.

The intuition: we don't want (or need) to walk the entire checkpoint chain. From some checkpoint C, the parent checkpoint Cp has strictly less information (fewer messages, given the append only nature of our message histories) UNLESS C is the result of summarization. Thus, to get the full history of messages, it is sufficient to take the most recent checkpoint C, and all "pre-summarization checkpoints", i.e., those checkpoints in the chain reachable from C which occurred right before a summarization.

Then we simply need an efficient way to detect all summarizations. We don't have a general summarization tracking like in the codegen workflow, but we can approximate it: detect the presence of RemoveMessage in the message channel writes, OR detect a case where the entire messages blob decreases in size from one checkpoint to the next. Either serve as signals that summarization happen. From these, we can reconstruct the entire history of a run in O(1) sql queries (4 to be exact) vs O(n) under the naive approach (where n is the total number of checkpoints in a run !!!!).

Validated locally against my dev DB, the heuristic had perfect precision and recall.

@jtoman
jtoman requested a review from shellygr September 4, 2026 17:52
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.

2 participants