Skip to content

perf: don't write auto-saved values or recoverable state that did not change - #29

Merged
metalwarrior665 merged 1 commit into
masterfrom
perf/skip-unchanged-auto-saved
Nov 17, 2026
Merged

metalwarrior665 merged 1 commit into
masterfrom
perf/skip-unchanged-auto-saved

Conversation

@metalwarrior665

Copy link
Copy Markdown
Member
  • Auto-saved values were written on every persistState. This covers KeyValueStore::get_auto_saved_value, which the SDK's Actor::use_state uses. Every value was written on every event, changed or not, at the periodic saves, a migration, an abort and the end of a run. In google-maps-rs that rewrote ENQUEUEING_STATE every minute. Each auto-saved value now remembers the record it last saved, loaded or was set_valued to, and is written only when it differs.
  • A state that never changes is never written. Both auto-saved values and RecoverableState (the crawler's statistics, request-list position and session pool) now count a missing record as holding the initial state, which a run would restore to anyway. Before, the default was written once.

Tests:

  • auto_saved_values_are_written_only_when_they_change covers a default left unchanged, a loaded value, a change, and a value set on the key.
  • an_unchanged_state_is_not_saved_again and saves_on_an_interval_when_the_state_changed are updated for the initial state. The first two failed before the change.

Generated by Claude Code

… change

`get_auto_saved_value` values (the SDK's `Actor::use_state`) were written
again on every `persistState` event, changed or not. Each now remembers the
record it last saved, loaded or was set to, and is written only when it
differs.

Both auto-saved values and `RecoverableState` also count a missing record as
holding the initial state, which a run would restore to anyway: a state that
never changes is never written (before, its default was written once).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0148RYR4BTGyCYHENSRZjC3S
@metalwarrior665
metalwarrior665 merged commit 19099a1 into master Nov 17, 2026
6 of 7 checks passed
metalwarrior665 pushed a commit that referenced this pull request Nov 18, 2026
…'s type_complexity

master's check job fails on it since #29.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0148RYR4BTGyCYHENSRZjC3S
metalwarrior665 added a commit that referenced this pull request Nov 18, 2026
…key up to 3.1M (#30)

* perf: grow the request queue's dedup cache from 8 KiB, keeping every key up to 3.1M

The cache was a fixed 1M-slot direct-mapped table (8 MiB from the first add), so keys that
landed in the same slot replaced each other: it kept 95% of 100k keys, 64% of 1M and 45% of
2M, where the LRU of JS keeps up to 2M exactly. Each forgotten key costs a backend add when it
is seen again.

It is now a hash table of the same 64-bit fingerprints with linear probing. It starts at 8 KiB
on the first add and doubles at 3/4 full, placing the keys again from their fingerprints, up
to 4M slots (32 MiB): every key is kept up to about 3.1M. Past that, a new key replaces the
one in its home slot, so the table stays at most 3/4 full.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0148RYR4BTGyCYHENSRZjC3S

* chore: name the type of an auto-saved value's last record, for clippy's type_complexity

master's check job fails on it since #29.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0148RYR4BTGyCYHENSRZjC3S

---------

Co-authored-by: Claude <noreply@anthropic.com>
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