Skip to content

Adds brotli arena allocator - #279

Merged
garretrieger merged 2 commits into
w3c:mainfrom
garretrieger:brotli_arena
Oct 28, 2026
Merged

garretrieger merged 2 commits into
w3c:mainfrom
garretrieger:brotli_arena

Conversation

@garretrieger

Copy link
Copy Markdown
Contributor

Internally brotli allocates on each instance creation some large memory structures (eg. 32mb hash table). Under the right conditions this can result in high setup cost per instance. Switch brotli's allocator to an arena which re-uses a fixed buffer. Sized at 256mb which should be sufficient for the vast majority of IFT encoder brotli operations. If arena size is exceeded allocation falls back to 'new'.

Updates Compiler's usage of TableKeyedDiff to use a shared brotli binary diff instances so the arena gets reused across subsequent diff operations.

Internally brotli allocates on each instance creation some large memory structures (eg. 32mb hash table). Under the right conditions this can result in high setup cost per instance. Switch brotli's allocator to an arena which re-uses a fixed buffer. Sized at 64mb which should be sufficient for the vast majority of IFT encoder brotli operations. If arena size is exceeded allocation falls back to 'new'.

Updates Compiler's usage of TableKeyedDiff to use a shared brotli binary diff instances so the arena gets reused across subsequent diff operations.
@garretrieger
garretrieger merged commit 2fcaa01 into w3c:main Oct 28, 2026
3 checks passed
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