Skip to content

A version check answers a current caller without walking the cluster - #511

Open
bjmeetsfo wants to merge 2 commits into
mainfrom
oss/a-current-caller-is-answered-without-a-walk
Open

A version check answers a current caller without walking the cluster#511
bjmeetsfo wants to merge 2 commits into
mainfrom
oss/a-current-caller-is-answered-without-a-walk

Conversation

@bjmeetsfo

Copy link
Copy Markdown
Collaborator

Asking whether the topology has moved is how a caller avoids fetching it:
send the version you hold, and the metaserver says whether there is anything
newer. The answer that cost the most to produce was the one that says no --
and that is the answer almost every check gets, because callers ask far more
often than the topology changes.

Two things made it expensive.

It collected every table and every recorded event newer than the caller's
version, before deciding there were none. Nothing can be newer than a caller
who is already current: a table is stamped with the version
record_topology_event returns, which is the global version as it stood when
it was bumped, so no table and no event can carry one above it.

It also counts how many servers, proxies and tables are normal, frozen and
dropped -- and walked each collection once per state. Nine walks of three
collections to answer one check. The states are disjoint, so one walk tallies
all three.

tables    before     after
   500     6.0 us    1.9 us
 2 000    25.1 us    8.7 us
 8 000   145.8 us   47.3 us

Three times faster, measured before and after back to back.

None of those nine numbers had a test. Counting a frozen server as a normal
one passed the whole suite, which is a poor position from which to rewrite
how all nine are computed, so there is a test now: one resource of each kind
in each state, and every count checked.

Asking whether the topology has moved is how a caller avoids fetching it:
send the version you hold, and the metaserver says whether there is anything
newer. The answer that cost the most to produce was the one that says no --
and that is the answer almost every check gets, because callers ask far more
often than the topology changes.

Two things made it expensive.

It collected every table and every recorded event newer than the caller's
version, before deciding there were none. Nothing can be newer than a caller
who is already current: a table is stamped with the version
record_topology_event returns, which is the global version as it stood when
it was bumped, so no table and no event can carry one above it.

It also counts how many servers, proxies and tables are normal, frozen and
dropped -- and walked each collection once per state. Nine walks of three
collections to answer one check. The states are disjoint, so one walk tallies
all three.

    tables    before     after
       500     6.0 us    1.9 us
     2 000    25.1 us    8.7 us
     8 000   145.8 us   47.3 us

Three times faster, measured before and after back to back.

None of those nine numbers had a test. Counting a frozen server as a normal
one passed the whole suite, which is a poor position from which to rewrite
how all nine are computed, so there is a test now: one resource of each kind
in each state, and every count checked.
@bjmeetsfo
bjmeetsfo requested a review from superhaiou as a code owner August 31, 2026 06:05
# Conflicts:
#	crates/temporalstore-rust/src/meta.rs
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