Skip to content

db/seg: precompute mask in patternTable to match posTable#21016

Closed
benderrobert wants to merge 1 commit intoerigontech:mainfrom
benderrobert:fix-patterntable-mask
Closed

db/seg: precompute mask in patternTable to match posTable#21016
benderrobert wants to merge 1 commit intoerigontech:mainfrom
benderrobert:fix-patterntable-mask

Conversation

@benderrobert
Copy link
Copy Markdown
Contributor

Add mask uint16 to patternTable (mirroring posTable:79). Initialize in allocTable, use in nextPattern() loop instead of computing (1<<bitLen)-1 per iteration.

Add `mask uint16` to `patternTable` (mirroring `posTable:79`). Initialize in `allocTable`, use in `nextPattern()` loop instead of computing `(1<<bitLen)-1` per iteration.
@AskAlexSharov
Copy link
Copy Markdown
Collaborator

currently patternTables using 1G ram inside erigon. Adding more fields there will increase ram usage.

Speed benefits are also unclear

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves decompression hot-path performance in db/seg by precomputing the Huffman lookup mask for patternTable (similar to the existing posTable approach) and reusing it during pattern decoding.

Changes:

  • Added mask uint16 to patternTable to cache (1<<bitLen)-1.
  • Initialized the mask once in patternArena.allocTable.
  • Switched Getter.nextPattern() to use the precomputed mask instead of recomputing it per loop iteration.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@benderrobert
Copy link
Copy Markdown
Contributor Author

benderrobert commented May 8, 2026

currently patternTables using 1G ram inside erigon. Adding more fields there will increase ram usage.

Speed benefits are also unclear

Yeah after re bench in local, its not that optimize than I thought. Closed now

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