Skip to content

Increase the default auto alllocate chunk size#6534

Merged
jasnell merged 1 commit intomainfrom
jasnell/streams-increase-default-auto-allocate-chunk-size
Apr 8, 2026
Merged

Increase the default auto alllocate chunk size#6534
jasnell merged 1 commit intomainfrom
jasnell/streams-increase-default-auto-allocate-chunk-size

Conversation

@jasnell
Copy link
Copy Markdown
Collaborator

@jasnell jasnell commented Apr 8, 2026

From 4KB to 64KB. This increases the default chunk size for default reads on internal streams, which should reduce the number of individual reads for larger payloads when piping data or iterating over the stream.

From 4KB to 64KB. This increases the default chunk size
for default reads on internal streams, which should reduce
the number of individual reads for larger payloads when
piping data or iterating over the stream.
@jasnell jasnell requested review from danlapid, guybedford and npaun April 8, 2026 20:36
@jasnell jasnell requested review from a team as code owners April 8, 2026 20:36
Copy link
Copy Markdown
Contributor

@ask-bonk ask-bonk bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm Bonk, and I've done a quick review of your PR.

This PR increases the default auto-allocate chunk size for byte streams from 4KB to 64KB to reduce read count for larger payloads.

  1. [HIGH] Ungated behavioral change: The default chunk size for byte-stream default reads is user-observable (it determines the buffer size passed to pull() via byobRequest.view and the chunk sizes returned by reader.read()). Changing from 4KB to 64KB without a compat flag is a breaking change for deployed workers that depend on the old size. The existing noAutoAllocateChunkSize flag controls whether the default is applied, not what value it is. This needs its own compat flag or should be gated behind an existing one.
  2. [LOW] Stale comment: The legacy-path comment still says "default to 4096".

This review was generated by an AI assistant and may contain inaccuracies.

@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk bot commented Apr 8, 2026

I'm Bonk, and I've done a quick review of your PR.

This PR increases the default auto-allocate chunk size for byte streams from 4KB to 64KB. I posted a review on PR #6534 with the following findings:

  1. [HIGH] Ungated behavioral change: The auto-allocate chunk size is observable by user code — it determines the buffer size in byobRequest.view during pull() and the chunk sizes returned by reader.read(). Changing this 16x without a compatibility flag affects all existing workers on the legacy code path that don't explicitly set autoAllocateChunkSize. The existing noAutoAllocateChunkSize compat flag only controls whether a default is applied, not what value it is. This needs a new compat flag.

  2. [LOW] Stale comment: The comment at standard.c++:3041 still says "default to 4096" and the comment in common.h:118 now reads 64 * 1024 where "64KB" would be more readable.

github run

Copy link
Copy Markdown
Member

@npaun npaun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have data from local testing, or are we going to have to try it live to see if helps?

@jasnell
Copy link
Copy Markdown
Collaborator Author

jasnell commented Apr 8, 2026

Up to 80% faster TTLB on a 1 MB payload.

@jasnell jasnell merged commit 5138dd5 into main Apr 8, 2026
31 of 32 checks passed
@jasnell jasnell deleted the jasnell/streams-increase-default-auto-allocate-chunk-size branch April 8, 2026 21:24
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.

2 participants