Skip to content

STOR-5615: Count full replay memory for JSRPC calls - #7558

Merged
apeacock1991 merged 2 commits into
mainfrom
apeacock/STOR-5615-replay-memory-budget
Sep 28, 2026
Merged

apeacock1991 merged 2 commits into
mainfrom
apeacock/STOR-5615-replay-memory-budget

Conversation

@apeacock1991

Copy link
Copy Markdown
Contributor

Each JSRPC call now reports one replay memory estimate, whether or not it gets a reservation.

  • The reservation counts the whole serialized buffer, not just the used bytes. The call plan keeps the whole buffer, so the budget undercounted it before.
  • Calls without a reservation track the same bytes as the reservation. They used to track only the buffer, without the call metadata and retry state.

The observer's budget and demand metric now measure calls the same way. Demand no longer depends on whether a reservation succeeds.

@apeacock1991
apeacock1991 requested review from a team as code owners September 28, 2026 09:12
@ask-bonk

ask-bonk Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Since last review: 0 resolved, 0 still open, 0 new.
LGTM!

Carried forward from the last review: kj-style (no author changes in their files since then; earlier findings stand)

Not re-run: tests, api-compat, docs, compat-flags, design-simplicity, jsg-gc, memory-safety (no author changes in their files since the last review)


Reviewed commit: 3236e38b · github run

Comment thread src/workerd/api/worker-rpc.c++ Outdated
@apeacock1991
apeacock1991 force-pushed the apeacock/STOR-5615-replay-memory-budget branch from b5a8214 to 12e2696 Compare September 28, 2026 09:24
@apeacock1991
apeacock1991 force-pushed the apeacock/STOR-5615-replay-memory-budget branch from 12e2696 to aa2413b Compare September 28, 2026 09:42
@apeacock1991
apeacock1991 force-pushed the apeacock/STOR-5615-replay-memory-budget branch 3 times, most recently from 2f66804 to b2b5f30 Compare September 28, 2026 13:00
The replay memory budget is a resource limit, but its hook was on
RequestObserver, so an embedder had to enforce the limit in its
metrics code. Move tryReserveActorCallReplayMemory() to
LimitEnforcer. The default still refuses every reservation, so
workerd's own server sends JSRPC calls without retries, as before.

RequestObserver keeps the measurements. It now tracks every
replayable call, including those with a reservation, so demand
doesn't depend on the budget. The new
recordActorCallReplayMemoryRejected() records each call sent
without retries because the reservation was refused.
The replay memory reservation counted the used length of the
serialized arguments, but the call plan keeps the whole serializer
buffer. Tracked demand counted the buffer capacity, but not the call
metadata or retry state.

Count the buffer capacity in the reservation, and track the same
bytes. The budget and the demand metric now use the same estimate
for each call.

Calls whose retry policy allows no retries used to take a
reservation too, and held it until they settled even though they
retain nothing to replay. Enough of them could fill the budget and
stop other calls from retrying. They now neither reserve nor track
replay memory.
@apeacock1991
apeacock1991 force-pushed the apeacock/STOR-5615-replay-memory-budget branch from b2b5f30 to 3236e38 Compare September 28, 2026 14:02
@apeacock1991
apeacock1991 merged commit b37c987 into main Sep 28, 2026
25 of 26 checks passed
@apeacock1991
apeacock1991 deleted the apeacock/STOR-5615-replay-memory-budget branch September 28, 2026 15:16
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.

3 participants