Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2.2: Optimize AppendVec / BufferedReader buffer sizes and alloc strategy (backport of #5457) #5487

Open
wants to merge 1 commit into
base: v2.2
Choose a base branch
from

Conversation

mergify[bot]
Copy link

@mergify mergify bot commented Mar 25, 2025

Problem

BufferedReader instances allocate significantly more memory than is optimal. This creates significant dropping pressure and slows down file reading from disk.

Summary of Changes

This adjusts BufferedReader instances to use 4KiB stack buffers for reads that don't require account data. The instance that does require account data starts with a 1MiB heap buffer and will resize once to worst case (~10MiB) account data size if an account is encountered that doesn't fit in the 1MiB buffer. This is optimized for the typical case where most accounts are token accounts of roughly ~300b.

BufferedReader had to be made generic to support both stack and heap allocated buffers, which adds a small amount of complexity, but gives us the significant advantage of not having to heap allocate every instance.


This is an automatic backport of pull request #5457 done by [Mergify](https://mergify.com).

@mergify mergify bot requested a review from a team as a code owner March 25, 2025 22:23
@mergify mergify bot assigned cpubot Mar 25, 2025
@cpubot cpubot force-pushed the mergify/bp/v2.2/pr-5457 branch from ab6a31e to 1e851d0 Compare March 25, 2025 23:14
@alessandrod
Copy link

why backport: file-io is active in 2.2, we're making it faster

@t-nelson
Copy link

@mergify rebase

…5457)

* Optimize default BufferedReader buffer sizes

* Allow configurable buffer backing in BufferedReader

(cherry picked from commit 06b96e4)
Copy link
Author

mergify bot commented Mar 26, 2025

rebase

✅ Branch has been successfully rebased

@t-nelson t-nelson force-pushed the mergify/bp/v2.2/pr-5457 branch from 1e851d0 to aec8616 Compare March 26, 2025 18:10
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.3%. Comparing base (fcba40a) to head (aec8616).

Additional details and impacted files
@@           Coverage Diff           @@
##             v2.2    #5487   +/-   ##
=======================================
  Coverage    83.3%    83.3%           
=======================================
  Files         800      800           
  Lines      370256   370299   +43     
=======================================
+ Hits       308537   308624   +87     
+ Misses      61719    61675   -44     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

4 participants