Skip to content

docs(contrail): measure the first zxcvbn call's CPU on Cloudflare - #171

Merged
aRustyDev merged 1 commit into
mainfrom
docs/zxcvbn-first-call-cputime
Nov 14, 2026
Merged

aRustyDev merged 1 commit into
mainfrom
docs/zxcvbn-first-call-cputime

Conversation

@aRustyDev

Copy link
Copy Markdown
Owner

What

The owner reopened D-023 to check the Cloudflare cpuTime of the first strength check, the one figure #170 left as a local proxy. This
records it and changes no behaviour.

  • .agents/plans/contrail/research/0015-zxcvbn-worker-cost.md: section 4.2 (the method, the figures, the controls, the caveats) and the
    figures in sections 0, 4, 5 and 6.
  • .agents/plans/contrail/DEVIATIONS.md, D-023: the "not measured on Cloudflare" clause is replaced by the figure, and the row says the owner
    reopened it for this. The rule stays as confirmed.
  • crates/thrust-core/src/auth.rs: the doc comment on password_is_strong carries the figure. Comment only.

Findings (Cloudflare, cpuTime, the Woven account)

Result
First zxcvbn call in a fresh isolate median 60.5 ms, 95% bootstrap interval 54.5 to 64.0, above a cold start of about 25 ms
A cold isolate's whole first request median 85 ms, p90 146 ms, max 274 ms
A warm check 1 to 2 ms (0.5 ms above the S arms on average)
The 2 MiB bigger module, on a cold start nothing measurable: cold medians 26 ms (baseline) and 25 ms (variant), difference -1 ms, interval -9 to 5
Against the bar set before measuring (no more than one argon2 hash, about 45 ms p50) missed by about 15 ms at the median (1.3 times one hash)

How it was measured: two requests to POST /internal/operator/users, both refused with 400 before any hashing (so no argon2 is in the figure),
short (zxcvbn never runs) and abcdefghijkl (zxcvbn refuses it, so the dictionaries are built); three arms (baseline build + S, variant build +
S, variant build + Z), six rounds each, rotated; each round a new Worker. A request above 10 ms is a cold one (warm ones cost 1 to 4 ms in every arm;
the result is the same at 5, 10 and 15 ms). The first call is median(vZ cold) - median(S cold). Every one of the six variant-Z rounds has a cold median above
every one of the twelve S rounds (76.5 to 91 ms against 41 or less).

A first call blocks its isolate for about 85 ms, so concurrent requests go to new isolates and each builds the dictionaries again: 94 of 222
variant-Z requests were cold against 49 and 61 of 222 for the S arms. After a deploy or a scale-out, concurrent sign-ups pay the first call once per
isolate. The local figures (30 ms on workerd, 8 ms native) understated the platform by 2 to 8 times.

Left open on purpose

  • Bar 3 is a judgement and the owner can move it. 60.5 ms is 1.3 times one hash. The platform's CPU limit is far above it (research/0012), and a
    sign-up that passes the check pays the hash as well; the cost is latency and CPU on the first check in each isolate, multiplied by concurrency.
  • D-023 is not changed. The rule stays as confirmed. What counts against the crate is now measured: 60.5 ms of CPU per fresh isolate, and the
    check-deps.sh conflict from docs(contrail): measure what the zxcvbn crate would cost the Worker #170 (it needs a port and an adapter crate). Size is not the obstacle.
  • Whether the Rust crate scores as Python's zxcvbn does, its panic exposure, and the cost of matching a long password on the platform (native: 3.7 to
    4.4 ms for 72 characters) are not measured.
  • The harness (driver, summary, the cold-cluster analysis, the variant patch) is not in this PR. It is refactor(scripts): the argon2 measurement signs in through Plane's route #146's pattern with a new Worker per round, the
    token in --secrets-file, and a preflight that refuses to run over an existing name. It can be added under scripts/ if the owner wants it kept.

Checks and what went wrong on the way

  • A control did not behave as I pre-registered. On the S arms, the first request of a same-connection sequence minus the later ones was 0 to 45 ms
    (bS: 21, 45, 0, 26, 40, 25; vS: 0.5, 0, 0, 21, 26, 37.5) where I expected about 0: the new connection sometimes reaches a fresh isolate, which pays a cold
    start that is not zxcvbn. So the sequences are not used for the figure (the variant-Z sequences' median of 75.8 contains a cold start), and the note says
    so. The figure comes from the cold-cluster comparison, in which both sides pay the cold start.
  • A first pilot was wrong in two ways, and the design changed: 23 of 111 responses came from the previous version's isolates seconds after a redeploy
    (builds were mixed), and the second burst was not warm (concurrent requests keep creating isolates). The full run uses a new Worker per round.
  • Plumbing: 666 requests, 666 platform records, none not 400, none with an outcome other than ok, no round with more than one version. The
    baseline's wasm lacks the dictionary and the variant's has it (the run refuses to start otherwise).
  • Teardown, verified: all 19 Workers (18 rounds and the tail consumer) answer "does not exist" (code 10007), and the account has the one KV namespace it
    had before. The run refused to start if any of those names or the KV title existed, because a deploy on an existing name overwrites that Worker.
  • Caveats: one account, one colo (not recorded), one session; cpuTime has a resolution of 1 ms; the bootstrap resamples requests, so its interval is a
    little narrower than it should be (the per-round comparison does not have that problem); one 12-character password; the memory adapter set.
  • cargo check -p thrust-core after the comment edit. The variant code was throwaway and is not in this PR.

Refs: #44. Closes nothing: #44 is already closed.

🤖 Generated with Claude Code

The owner reopened D-023 to check the Cloudflare cpuTime of the first
strength check, the one figure #170 left as a local proxy. This records
it, and changes no behaviour.

On Cloudflare, with the #146 harness (a tail consumer writes cpuTime to
KV), the first zxcvbn call in a fresh isolate costs a median 60.5 ms of
CPU above a cold start of about 25 ms (95% interval 54.5 to 64.0). A
warm check is 1 to 2 ms. 666 requests over 18 fresh Workers, two
requests that are both refused before any hashing, three arms (baseline
build, variant build, variant build with zxcvbn); all six variant-Z
rounds lie above all twelve S rounds. The 2 MiB bigger module costs a
cold start nothing measurable (cold medians 26 and 25 ms).

That misses the bar set before measuring (no more than one argon2 hash,
about 45 ms p50) by about 15 ms at the median. A first call blocks its
isolate, so concurrent requests start more isolates and each builds the
dictionaries again. The local figures understated the platform by 2 to
8 times.

One control did not behave as pre-registered: the first request of a
same-connection sequence on the S arms cost 0 to 45 ms where 0 was
expected, because the new connection sometimes reaches a fresh isolate.
The sequences are therefore not used for the figure, and the note says
why. A first pilot also showed that a redeploy leaks traffic to the
previous version for seconds, so the run uses a new Worker per round.
The 19 Workers and the KV namespace were deleted and checked.

The D-023 row and the doc comment on password_is_strong carry the figure.
D-023 is not changed: the rule stays as confirmed until the owner decides.

Refs: #44
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@aRustyDev
aRustyDev merged commit b9af041 into main Nov 14, 2026
35 checks passed
@aRustyDev
aRustyDev deleted the docs/zxcvbn-first-call-cputime branch November 14, 2026 23:54
This was referenced Nov 15, 2026
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.

1 participant