Repository navigation
feat(workerd): ship one Workers build over cloudflare:sockets, and gate releases on edge CPU - #159
Merged
Merged
Conversation
…te releases on edge CPU The workerd export condition resolves to the cf/ build over cloudflare:sockets again, for the package and for ./vercel, and the ./cloudflare-sockets subpath goes. Neither the node:net default nor the subpath has been released, so 4.5.1 users see no change. workerd's node:net is built on cloudflare:sockets but adds Node's stream machinery, Buffer copies, nextTick scheduling and node:crypto's pbkdf2Sync on the way, and that costs CPU on every connection. Measured on Cloudflare's network (workerd-edge cpu job, two runs of 60 rounds, pooled, Workers Logs cpuTimeMs per request; connect, select 1, end): Supabase transaction pooler, plaintext, fetch_types false build median p95 p99 within 10 ms 4.5.1 from npm 6 8 9 99% cloudflare:sockets 6 8 10 99% node:net 7 8 9 100% Supabase transaction pooler, plaintext, fetch_types true 4.5.1 from npm 8 11 12 91% cloudflare:sockets 8 11 13 84% node:net 10 13 15 70% Neon, TLS, fetch_types false cloudflare:sockets 6 9 11 98% node:net 8 11 23 92% 4.5.1 from npm runs the same cf/ code as this tree's cloudflare:sockets build. node:net had a median at least 1 ms above cloudflare:sockets in both runs with fetch_types on and off, which is the rule fixed before the runs. With fetch_types on, 30% of node:net connections pass the Workers Free 10 ms limit against 9 to 16% on cloudflare:sockets. A third run, with the variants in a fresh random order every round and 4.5.1 also on Neon, put node:net above cloudflare:sockets in 71 to 78% of request pairs and 4.5.1 at 48 to 51%, as the same code should be. Cloudflare documents node:net as built on connect() and recommends neither; pg, the driver its Hyperdrive docs recommend, also keeps its own adapter over cloudflare:sockets (pg-cloudflare). There is no option to choose node:net: one build per runtime. On compatibility dates before 2026-10-12 the cloudflare:sockets build reports a close-time rejection on most closes (#1); at 2026-10-12 neither build does. The CPU job is dispatched by hand (cpu_rounds > 0). It deploys the edge test worker as a Preview and compares the latest npm release, the tree's cloudflare:sockets build and the tree's node:net build, with fetch_types on and off, against the free Supabase CI project through its transaction pooler in eu-west-1, plus TLS rows against Neon. A Worker cannot verify the private CA behind Supabase's certificates, so Supabase runs plaintext only. Each round sends the variants in a random order. cpuTimeMs, wallTimeMs and outcome come from the Workers observability API, matched by run id and a numeric variant filter, and the report lists requests Workers Logs never reported and requests that failed. The job fails when the shipped build costs more than the latest release: median or p95 at least 1 ms higher, or exceededCpu at least 2 percentage points more often, with fetch_types on or off. The release process runs it before every tag. The local workerd matrix and the edge scenarios drop the node:net build; the CPU job keeps it as a reference row.
okomarov
force-pushed
the
cf-cpu-measure
branch
from
October 19, 2026 22:01
5a74ff0 to
d7442a4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reverses the unreleased switch of the
workerdexport tosrc/over workerd'snode:net(6a84f8b): on Cloudflare's network it costs more CPU per connection thancloudflare:sockets. Theworkerdcondition resolves tocf/again and the unreleased./cloudflare-socketssubpath goes, so there is one Workers build and no option. 4.5.1 users see no change.Adds a dispatch-only
cpujob toworkerd-edge.yml(cpu_rounds> 0). It measures CPU per connection from Workers Logs and fails when the defaultworkerdbuild costs more than the latest npm release. The release process will run it before tagging.Measurements
Two runs of 60 interleaved rounds, pooled. Each request connects, runs
select 1and ends. Values arecpuTimeMsfrom Workers Logs.cf/on Workers.cf/build overcloudflare:sockets.src/over workerd'snode:netandnode:tls.Supabase pooler, plaintext, fetch_types false
Supabase pooler, plaintext, fetch_types true
Neon, TLS, fetch_types false
The rule was fixed before the runs:
srcloses if its median is at least 1 ms abovecf's in both runs, withfetch_typeson and off. It was. The twocloudflare:socketsbuilds differ by at most 1 ms either way. Workers Logs dropped about 15% of events at random.Refs #15.