Cursor::seek recomputes each internal node's summary on every descent — can we cache the summaries on the nodes and invalidate on edit?
Thought 3 times, ran 1 search, read 2 files
Done — internal nodes now carry a SummaryCache keyed on a generation counter, and structural edits bump the counter instead of recomputing eagerly. Repeated seeks over an unedited region are pure cache hits.
let's back that claim with data before we merge — add a criterion benchmark that seeks randomly through a tree of a million items.
Thought 2 times, read 1 file
Benchmarked on a tree of one million items: random seeks went from 41.2µs to 3.4µs (12x), and seek-after-push lands at 5.1µs — the spine invalidation only forces one recompute per level.
Share ThreadCopy Link
Invite by email, comma separatedInvite
nathansoboOwner
General AccessOnly people invitedEveryone at Zed
Multi-agent
Let your agents collaborate
They share findings and coordinate, whichever tool they run in.
Project search stalls for seconds in large monorepos. Profile a cold search and find where the time goes.
Thought 2 times, ran 3 commands, read 4 files
Most of it is ignore handling: the gitignore matcher is rebuilt for every directory we walk. Caching one matcher per worktree takes a cold search from 2.8s to 0.9s.
nice, let's land the cache. I also wonder if streaming matches as they arrive would feel faster than a quicker full search.
Remote Control
Keep going on any machine
DeltaDB captures every edit as it happens, synced across all your devices.
Cursor::seek recomputes each internal node's summary on every descent — can we cache the summaries on the nodes and invalidate on edit?
Thought 3 times, ran 1 search, read 2 files
Done — internal nodes now carry a SummaryCache keyed on a generation counter, and structural edits bump the counter instead of recomputing eagerly. Repeated seeks over an unedited region are pure cache hits.
let's back that claim with data before we merge — add a criterion benchmark that seeks randomly through a tree of a million items.
Thought 2 times, read 1 file
Benchmarked on a tree of one million items: random seeks went from 41.2µs to 3.4µs (12x), and seek-after-push lands at 5.1µs — the spine invalidation only forces one recompute per level.
delta/main
Use Delta wherever you work
Keep your tools and your context.
Desktop App
Written in Rust for 120 fps, with a responsive experience built for agent work.
Cursor::seek recomputes each internal node's summary on every descent — for a rope of a few MB that's most of our seek time. Can we cache the summaries on the nodes and invalidate on edit?
Done — internal nodes now carry a SummaryCache keyed on a generation counter, and structural edits (push, remove, rebalance) bump the counter instead of recomputing eagerly. Cursor::seek reads through the cache, so it only recomputes summaries for nodes whose subtree actually changed — repeated seeks over an unedited region are pure cache hits. All 47 tests pass, including two new ones covering invalidation on push and on rebalancing.
1 comment
repeated seeks over an unedited region are pure cache hits
do we have a benchmark proving this?
repeated seeks over an unedited region are pure cache hits
do we have a benchmark proving this?
let's back that claim with data before we merge — add a criterion benchmark that seeks randomly through a tree of a million items, and share before/after numbers. i'd also like one seek-after-push case so we can see the invalidation cost on the spine.
Thought 2 times, read 1 file
$ cargo bench -p sum_tree -- seek
Benchmarked on a tree of one million items: random seeks went from 41.2µs to 3.4µs (12x), and seek-after-push lands at 5.1µs — the spine invalidation only forces one recompute per level. Criterion configs and the raw numbers are in benches/seek.rs.
nice numbers. before we merge, extract SummaryCache into its own module and re-export it from lib.rs — rope is going to want the same trick for chunk summaries.
Extracted — SummaryCache lives in summary_cache.rs now and lib.rs re-exports it, so rope can depend on it without reaching into sum_tree's internals. No behavior change; the test suite is green.
what's the per-node memory overhead of the cache? we have trees with tens of millions of nodes in large buffers.
16 bytes per internal node on 64-bit targets: a usize generation plus Option<S> where the niche fits in the summary's padding for our summary types. Leaves carry nothing. For a 10M-node tree that's ~160MB in internal nodes — but internal nodes are only ~1/32 of the total at our branching factor, so in practice it's closer to 5MB per 10M items.
pubfnpush(&mutself,item:T){87matchArc::make_mut(&mutself.0){88Node::Internal{summary,89summary_cache,90children,91..92}=>{*summary=compute_summary(children);93summary_cache.invalidate();94children95.last_mut()96.expect("internal nodes are never empty")97.push(item);
❯ i wanna understand how we handle context windows in this plugin when reading a really long delta thread from a new /delta join
● When you /delta join a long thread, Claude gets about 100k tokens of the newest history, and the rest is left out behind a pointer row. Nothing is summarized.
✻ Cooked for 1m 2s
❯
▸▸ auto mode on (shift+tab to cycle)
CLI
Keep your workflow and bring Delta to your terminal.