[PR #94] [MERGED] Speed and memory usage improvements for the decoder. #698

Open
opened 2026-01-29 20:50:25 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/google/brotli/pull/94
Author: @szabadka
Created: 5/7/2015
Status: Merged
Merged: 5/7/2015
Merged by: @szabadka

Base: masterHead: master


📝 Commits (1)

  • 83aa24d Speed and memory usage improvements for the decoder.

📊 Changes

11 files changed (+117 additions, -35 deletions)

View changed files

📝 .gitignore (+1 -0)
📝 dec/bit_reader.c (+2 -2)
📝 dec/bit_reader.h (+9 -7)
📝 dec/decode.c (+33 -18)
📝 dec/huffman.c (+0 -1)
📝 dec/huffman.h (+0 -1)
dec/port.h (+60 -0)
📝 dec/safe_malloc.c (+2 -1)
📝 dec/safe_malloc.h (+0 -2)
📝 enc/port.h (+9 -3)
📝 setup.py (+1 -0)

📄 Description

  • Change order of members of bit reader state structure.
  • Remove unused includes for assert. Add BROTLI_DCHECK
    macros and use it instead of assert.
  • Do not calculate nbits in common case of ReadSymbol.
  • Introduce and use PREDICT_TRUE / PREDICT_FALSE macros.
  • Allocate less memory in the brotli decoder if it knows
    the result size beforehand. Before this, the decoder
    would always allocate 16MB if the encoder annotated the
    window size as 22 bit (which is the default), even if the
    file is only a few KB uncompressed. Now, it'll only
    allocate a ringbuffer as large as needed for the result file.
    But only if it can know the filesize, it's not possible
    to know that if there are multiple metablocks or too large
    uncompressed metablock.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/google/brotli/pull/94 **Author:** [@szabadka](https://github.com/szabadka) **Created:** 5/7/2015 **Status:** ✅ Merged **Merged:** 5/7/2015 **Merged by:** [@szabadka](https://github.com/szabadka) **Base:** `master` ← **Head:** `master` --- ### 📝 Commits (1) - [`83aa24d`](https://github.com/google/brotli/commit/83aa24dc8686b62177d776a3baab5f69badc1a78) Speed and memory usage improvements for the decoder. ### 📊 Changes **11 files changed** (+117 additions, -35 deletions) <details> <summary>View changed files</summary> 📝 `.gitignore` (+1 -0) 📝 `dec/bit_reader.c` (+2 -2) 📝 `dec/bit_reader.h` (+9 -7) 📝 `dec/decode.c` (+33 -18) 📝 `dec/huffman.c` (+0 -1) 📝 `dec/huffman.h` (+0 -1) ➕ `dec/port.h` (+60 -0) 📝 `dec/safe_malloc.c` (+2 -1) 📝 `dec/safe_malloc.h` (+0 -2) 📝 `enc/port.h` (+9 -3) 📝 `setup.py` (+1 -0) </details> ### 📄 Description - Change order of members of bit reader state structure. - Remove unused includes for assert. Add BROTLI_DCHECK macros and use it instead of assert. - Do not calculate nbits in common case of ReadSymbol. - Introduce and use PREDICT_TRUE / PREDICT_FALSE macros. - Allocate less memory in the brotli decoder if it knows the result size beforehand. Before this, the decoder would always allocate 16MB if the encoder annotated the window size as 22 bit (which is the default), even if the file is only a few KB uncompressed. Now, it'll only allocate a ringbuffer as large as needed for the result file. But only if it can know the filesize, it's not possible to know that if there are multiple metablocks or too large uncompressed metablock. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-29 20:50:25 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/brotli#698