Repository navigation
perf: read ahead only the records a listing of the store's keys finds - #48
Conversation
At `Actor::init`, every record of `InitOptions::prefetch_records` (and the tracked child runs) was read with its own GET. Most of them are state an earlier container of the run would have saved, so in a fresh run they do not exist and each GET answers 404: a run prefetching ten records made ten calls for nothing. Now the store's keys are listed once (pages of 1,000, at most 10), in the background beside the metadata read, and only the records listed are read, all at once after the listing. The first read of a record that is not listed is `None` without an API call. The input is still read at once, beside the listing, as a run nearly always has it. A record written or deleted through the SDK is read from the API again, as before. When the listing fails or the store holds more than 10,000 keys, each record is read as before. The listing is complete for records an earlier container wrote: the platform stores a record before it answers the write. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0148RYR4BTGyCYHENSRZjC3S
…more Paging through up to 10,000 keys would cost more than the reads it saves: a store holding more than one page (1,000 keys) has its records read one by one, in parallel, as before the listing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0148RYR4BTGyCYHENSRZjC3S
|
Two updates in a2ad836: The listing reads one page of keys now. A store holding more than one page (1,000 keys) has its prefetched records read one by one, in parallel, instead of being listed page after page up to 10,000. A listing takes about as long as a record read. I timed requests against a real run's default store (8 keys), 25 times each, interleaved, from outside the platform:
So a fresh run trades about ten missing-record reads for one listing that takes about as long as any one of them. 🤖 Generated with Claude Code https://claude.ai/code/session_0148RYR4BTGyCYHENSRZjC3S Generated by Claude Code |
At
Actor::init, each record ofInitOptions::prefetch_records(and the tracked child runs) got its own GET. A fresh run of google-maps-rs prefetches ~10 state records that mostly don't exist yet, so it sent ~10 GETs that all answer 404.What changed:
get_valueof a prefetched key that isn't listed returnsNonewith no API call.set_value/delete_valueof a key drops what was read ahead for it, so the next read goes to the API, as before.Fresh run: metadata + 1 listing + INPUT, where it used to be metadata + INPUT + one GET per prefetched key. Resumed run: the records that exist are fetched one round trip later, after the listing.
Generated by Claude Code