Skip to content

feat(kernel range reader): Add buffer pooling support for large reads on regional buckets#4848

Draft
abhishek10004 wants to merge 5 commits into
abhishek/support_vectored_readsfrom
abhishek/sync_pool
Draft

feat(kernel range reader): Add buffer pooling support for large reads on regional buckets#4848
abhishek10004 wants to merge 5 commits into
abhishek/support_vectored_readsfrom
abhishek/sync_pool

Conversation

@abhishek10004

Copy link
Copy Markdown
Collaborator

Description

Description

This PR introduces buffer pooling for large and vectored read operations to optimize memory usage and reduce garbage collection overhead. By reusing allocated buffers via a sync pool, we minimize memory churn during sequential and large file reads.

Note

Buffer pooling support for larger reads is only supported for regional buckets when kernel reader is enabled.

Key Changes

  • Buffer Pooling & Lifecycle Management (internal/fs/fs.go)

    • Integrated readBufferPool into read operations to dynamically allocate and recycle byte buffers for read requests (supported only for regional buckets with kernel reader enabled).
    • Implemented immediate buffer reclamation: unused buffers or zero-copy hits return their buffers to the pool right away.
    • Added callback handling to ensure borrowed buffers are properly returned to the pool after the caller finishes consuming the read data.
  • Buffer Limiting Utility (internal/util/util.go)

    • Added a zero-allocation helper function LimitBuffers(buffers [][]byte, limit int) [][]byte.
    • Reslices multi-buffer slices in-place to cap total data size without allocating new slice headers or arrays.
  • Testing (internal/fs/large_read_regional_test.go, internal/util/util_test.go)

    • Added unit tests for LimitBuffers covering boundary conditions, multiple buffer spans, and edge cases.
    • Introduced regional large read test suite (large_read_regional_test.go) verifying successful vectored reads on regional buckets and confirming proper fallback/error behavior (ENOTSUP) for zonal buckets or when kernel reader support is disabled.

Link to the issue in case of a bug fix.

b/530765312

Testing details

  1. Manual - Done
  2. Unit tests - Done
  3. Integration tests - NA

Any backward incompatible change? If so, please explain.

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