Skip to content

docs(contrail): measure what the zxcvbn crate would cost the Worker - #170

Merged
aRustyDev merged 1 commit into
mainfrom
docs/measure-zxcvbn-size
Nov 14, 2026
Merged

aRustyDev merged 1 commit into
mainfrom
docs/measure-zxcvbn-size

Conversation

@aRustyDev

Copy link
Copy Markdown
Owner

What

Measures the open question in D-023: would a zxcvbn port's dictionary be too big for the Worker? It would not. This records the numbers, and
changes no behaviour.

  • .agents/plans/contrail/research/0015-zxcvbn-worker-cost.md (new): the method, the figures, the controls, what was not measured.
  • .agents/plans/contrail/DEVIATIONS.md, D-023: "(not measured here)" and "with the bundle-size measurement still open" are replaced by the
    result. The rule stays as the owner confirmed it.
  • crates/thrust-core/src/auth.rs: the doc comment on password_is_strong said the dictionary's size "was not measured". Comment only.

Findings

Result
Worker bundle, base to with zxcvbn 3.1.1 4.756 MiB to 6.765 MiB (+2.01 MiB, +42%); the ADR-0090 reopen trigger is 20 MiB
Of which dictionary text 0.76 MiB (93,855 entries); the other 1.25 MiB is code, not decomposed
Startup (local profile window) 13.2 to 13.5 ms before, 13.5 to 15.5 ms after; target 300 ms
First strength check in an isolate about 30 ms on local workerd (31.2 to 32.8 ms over 5 cold starts, warm 2.0 to 3.0 ms); 8 ms native
scripts/check-deps.sh with the crate in thrust-core fails, 15 hits across five crates (wasm-bindgen, js-sys, web-sys); 0 on the base

So the reason D-023 gave, bundle size, does not hold. What counts against the crate is the guard, not the size: adopting it needs a port and an
adapter crate, as thrust-adapters-oidc has.

Left open on purpose

  • Cloudflare cpuTime of the first call (the plan's bar 3: no more than one argon2 hash, about 45 ms p50). The local figure is within 2x of
    it, so it is not settled. The deployed measurement reuses scripts/measure-argon2.sh and writes throwaway Workers to the owner's account; the
    owner chose not to run it now. The note says how.
  • Whether the Rust crate scores as Python's zxcvbn does, and its panic exposure under ADR-0006. Neither was measured.
  • D-023 is not reopened. The owner decides whether these numbers change it.

Checks

  • Base built twice: identical bytes. The dictionary text (a run of 12 consecutive entries from two lists) is in the called build once each and in neither the base nor the
    uncalled control.
  • One control did not hold, and the note says so: the build that references the crate but never calls it is +2,633 B (+0.053%) over the base,
    not equal. No dictionary and no crate path is in it and index.js is identical; the cause is not established. It bounds the noise at 0.1% of the delta.
  • The called build runs on local workerd: two passwords the old rule accepts and zxcvbn refuses (scores Zero and One) got 400, a strong one 204, a
    repeat 409, no token 401.
  • scripts/check-deps.sh on the base: exit 0, 0 hits (the control for the 15).
  • cargo check -p thrust-core after the comment edit. Nothing else in the tree changed; the variant code was throwaway and is not in this PR.

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

🤖 Generated with Claude Code

D-023 replaced Plane's zxcvbn score with a short rule because a zxcvbn
port "carries a frequency dictionary into the Worker (not measured)".
The owner confirmed it on 2026-11-14 with that measurement open. This
measures it and records the result, and changes no behaviour.

Built the deploy bundle (`worker-build --release . --no-default-features`)
from the base and with the crate called from `password_is_strong`:
4.756 MiB to 6.765 MiB (+2.01 MiB, +42%), against ADR-0090's 20 MiB
reopen trigger. The dictionary text is 0.76 MiB of that. Startup is
unchanged (13 to 15 ms locally). The first strength check in an isolate
builds the dictionaries: about 30 ms on local workerd, 8 ms native, not
measured on Cloudflare. So the reason D-023 gave does not hold.

What does count against the crate: it declares wasm-bindgen, js-sys and
web-sys on wasm32, which scripts/check-deps.sh forbids in thrust-core's
graph. Tried, the guard fails with 15 hits across five crates, and
passes with none on the base.

The uncalled-reference control was not byte-equal to the base (+2,633 B,
no dictionary and no zxcvbn path in it, cause not established); the note
says so. Not measured: Cloudflare cpuTime, whether the Rust crate scores
as Python's does, and its panic exposure.

The D-023 row and the doc comment on password_is_strong now say what was
measured, in place of "not measured". The rule itself is unchanged.

Refs: #44
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@aRustyDev
aRustyDev merged commit 6be18cf into main Nov 14, 2026
35 checks passed
@aRustyDev
aRustyDev deleted the docs/measure-zxcvbn-size branch November 14, 2026 22:58
aRustyDev added a commit that referenced this pull request Nov 14, 2026
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]>
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