Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

chore(ci): resize the stateright shard around the faster model checks (#79904)

Eli Reisman43b5460230a9
diff --git a/.github/workflows/ci-rust.yml b/.github/workflows/ci-rust.yml
index 1eb6ebe57c50..0327336a70ac 100644
--- a/.github/workflows/ci-rust.yml
+++ b/.github/workflows/ci-rust.yml
@@ -157,7 +157,7 @@ jobs:
"personhog-leader": 115,
"personhog-replica": 140,
"personhog-router": 38,
- "personhog-stateright": 700,
+ "personhog-stateright": 220,
"posthog-symbol-data": 19,
"property-defs-rs": 136,
"posthog-replay-anonymizer": 20,
@@ -296,8 +296,7 @@ jobs:
needs: [changes, affected]
if: needs.changes.outputs.rust == 'true'
runs-on: depot-ubuntu-24.04-4
- # stateright model checks need more headroom than the other shards
- timeout-minutes: ${{ contains(matrix.packages, 'personhog-stateright') && 40 || 20 }}
+ timeout-minutes: 20
permissions:
contents: read
env:
diff --git a/rust/.config/nextest.toml b/rust/.config/nextest.toml
index f0c5f8b9b459..09294ac6b0ae 100644
--- a/rust/.config/nextest.toml
+++ b/rust/.config/nextest.toml
@@ -7,10 +7,10 @@
# suite from saturating the runner while a cluster is up.
[test-groups]
k3s = { max-threads = 1 }
-# The two-partition double-zombie models are the stateright suite's long
-# pole (roughly 15x anything else in it). Their checkers explore
-# multi-threaded, so each gets the whole thread budget to itself instead
-# of contending with the rest of the suite mid-explore.
+# The two-partition epoch-fenced double zombie is the stateright suite's long
+# pole — 13M states, several times anything else in it. Its checker explores
+# multi-threaded, so it gets the whole thread budget to itself instead of
+# contending with the rest of the suite mid-explore.
stateright-heavy = { max-threads = 1 }
[[profile.default.overrides]]
@@ -19,7 +19,7 @@ test-group = 'k3s'
threads-required = 4
[[profile.default.overrides]]
-filter = 'package(personhog-stateright) & test(two_partitions_double_zombie)'
+filter = 'package(personhog-stateright) & test(epoch_fenced_two_partitions_double_zombie_is_safe)'
test-group = 'stateright-heavy'
threads-required = "num-cpus"
@@ -33,10 +33,11 @@ fail-fast = false
[profile.ci.junit]
path = "junit.xml"
-# The two-partition double-zombie model checks each saturate every core
-# (stateright spawn_bfs); running them concurrently on a small CI runner
-# roughly doubles both. Requiring all test threads runs them one at a
-# time with the full machine each.
+# Same reservation under the CI profile. Its sibling
+# `two_partitions_double_zombie_loses_acked_writes` used to be reserved too,
+# but it only asserts a counterexample exists and now stops at one, which
+# leaves it a few seconds long — reserving the machine for it just serialized
+# it against the rest of the suite for nothing.
[[profile.ci.overrides]]
-filter = 'package(personhog-stateright) and (test(two_partitions_double_zombie_loses_acked_writes) or test(epoch_fenced_two_partitions_double_zombie_is_safe))'
+filter = 'package(personhog-stateright) and test(epoch_fenced_two_partitions_double_zombie_is_safe)'
threads-required = "num-cpus"
diff --git a/rust/personhog-stateright/README.md b/rust/personhog-stateright/README.md
index 407565058db5..2ed49d20932b 100644
--- a/rust/personhog-stateright/README.md
+++ b/rust/personhog-stateright/README.md
@@ -77,9 +77,23 @@ Everything asserting that a property *holds* still explores exhaustively — an
The rule for touching one of these tests: adding an assertion that a discovery is *absent* means moving that run back to `explore`.
The early exit makes the run prove less, not less well.
+### How the threads are divided
+
+Every checker explores with as many threads as the machine has, and `.config/nextest.toml` reserves the whole thread budget for the one scenario big enough to want it (`epoch_fenced_two_partitions_double_zombie_is_safe`) so it does not contend with the rest of the suite mid-explore.
+
+Two things worth knowing before tuning this.
+BFS parallelizes poorly here — 14 checker threads buy under a 3x speedup — so a checker asking for every core does not get every core's worth of work done.
+And a single-threaded BFS reports the *shortest* path to each discovery, which makes a failure far easier to read, so there is a real argument for exploring the small scenarios on one thread and letting nextest supply the parallelism instead.
+
+That argument has not been measured on a CI-sized machine, and it is not measurable on a large one: reducing nextest's lane count on a 14-core laptop just idles cores rather than emulating a 4-core runner.
+Reserving judgement until it can be measured where it matters.
+
`generated / unique` is the duplicate-successor ratio, and `depth` is a racing maximum across checker threads, so it varies run to run and means nothing on its own.
Wall times move by up to 10% between runs of the same binary, so judge a change by its state counts and treat a timing difference under that as no difference.
+Only the exhaustive runs have stable counts.
+A run that stops at its counterexample (see below) reports how far it happened to get, which depends on thread count and scheduling, so its numbers are informational and not a gate.
+
## Coupling to production (drift prevention)
The protocol's *decision logic* is single-sourced: the model calls the
diff --git a/rust/personhog-stateright/tests/model_tests.rs b/rust/personhog-stateright/tests/model_tests.rs
index e7d10138bad4..1c1c1cea6df7 100644
--- a/rust/personhog-stateright/tests/model_tests.rs
+++ b/rust/personhog-stateright/tests/model_tests.rs
@@ -726,34 +726,29 @@ fn fencing_and_lease_gated_reads_together_close_the_double_zombie() {
..base()
};
// The two arms below that expect a stale read stop at it; the arm that
- // asserts none exists has to explore everything.
- let stale_reads_reachable = |variant, gated| {
+ // asserts none exists has to explore everything. Each arm reports under
+ // its own label, so their state counts stay comparable separately.
+ let stale_reads_reachable = |scenario, variant, gated| {
cfg(variant, gated)
- .explore_until(
- "fencing_and_lease_gated_reads_together_close_the_double_zombie",
- &["strong_reads_complete"],
- )
- .discovery("strong_reads_complete")
- .is_some()
- };
- let stale_reads = |variant, gated| {
- cfg(variant, gated)
- .explore("fencing_and_lease_gated_reads_together_close_the_double_zombie")
+ .explore_until(scenario, &["strong_reads_complete"])
.discovery("strong_reads_complete")
.is_some()
};
assert!(
- stale_reads_reachable(Variant::Current, true),
+ stale_reads_reachable("read_gate_alone", Variant::Current, true),
"the read gate alone must not close it: the honest owner serves a read missing the \
zombie's lost write"
);
assert!(
- stale_reads_reachable(Variant::EpochFenced, false),
+ stale_reads_reachable("fencing_alone", Variant::EpochFenced, false),
"fencing alone must not close it: the zombie still answers reads"
);
assert!(
- !stale_reads(Variant::EpochFenced, true),
+ cfg(Variant::EpochFenced, true)
+ .explore("fencing_and_read_gate_together")
+ .discovery("strong_reads_complete")
+ .is_none(),
"together they must close it"
);
}
@@ -835,17 +830,14 @@ fn prompt_detection_is_what_makes_the_read_gate_hold() {
// asserts there is none, so it has to explore everything.
assert!(
cfg(ClaimDetection::Delayed)
- .explore_until(
- "prompt_detection_is_what_makes_the_read_gate_hold",
- &["strong_reads_complete"],
- )
+ .explore_until("delayed_claim_detection", &["strong_reads_complete"])
.discovery("strong_reads_complete")
.is_some(),
"a claim outliving its lease must still leave stale reads reachable"
);
assert!(
cfg(ClaimDetection::Prompt)
- .explore("prompt_detection_is_what_makes_the_read_gate_hold")
+ .explore("prompt_claim_detection")
.discovery("strong_reads_complete")
.is_none(),
"dropping the claim with the registration must close them"