Skip to content

feat(block): implement per-writer mmap buffer pool for parallel uploads - #5273

Open
vipnydav wants to merge 1 commit into
masterfrom
parallel-upload/writer-buffer-pool
Open

vipnydav wants to merge 1 commit into
masterfrom
parallel-upload/writer-buffer-pool

Conversation

@vipnydav

@vipnydav vipnydav commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Description

Implements WriterBufferPool, a per-writer mmap-backed buffer pool implementing the Go Storage SDK's experimental.BufferPool interface for gRPC parallel uploads.

  • Per-writer pool with shared byte budget: Each Go SDK storage.Writer gets its own WriterBufferPool with a bounded block cache (capacity maxBlocksPerFile) while sharing one mount-wide atomic byte budget.
  • Get: Called when the writer holds no blocks to guarantee forward progress. Reuses a cached block if available, or deducts one block from the global budget (even below zero) and allocates via mmap.
  • TryGet: Non-blocking call for additional blocks. Reuses a cached block if available, or atomically reserves one block when enough global budget remains and allocates via mmap, returning false when budget is insufficient to throttle concurrency.
  • Put: Unmaps the buffer and returns its bytes to the global budget when over-committed or when the cache is full. Otherwise restores full block length and caches it for reuse.
  • Destroy: Drains the cache channel, unmaps all cached blocks, and returns their bytes to the global budget after the writer closes or aborts.
  • Fixed block size: Get and TryGet reject requests that do not match the configured block size, and Put ignores buffers with unexpected capacity.

Link to the issue in case of a bug fix.

b/548825047

Testing details

  1. Manual - NA
  2. Unit tests - Added.
  3. Integration tests - Automated.

Any backward incompatible change? If so, please explain.

No.

@vipnydav
vipnydav requested a review from a team as a code owner November 19, 2026 17:12
@github-actions github-actions Bot added the remind-reviewers Auto remind reviewers in attention set for review post 24hrs of inactivity on PR. label Nov 19, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces WriterBufferPool, an mmap-backed implementation of the Go Storage SDK's experimental.BufferPool interface designed for gRPC parallel uploads, along with comprehensive unit tests. The reviewer feedback suggests adding a destroyed atomic boolean flag to the pool to prevent use-after-destroy bugs and memory leaks. This flag should be set during Destroy and checked in Get, TryGet, and Put to safely handle late buffer operations.

Comment thread internal/block/writer_buffer_pool.go Resolved
Comment thread internal/block/writer_buffer_pool.go Resolved
Comment thread internal/block/writer_buffer_pool.go Resolved
Comment thread internal/block/writer_buffer_pool.go Resolved
Comment thread internal/block/writer_buffer_pool.go Resolved
@codecov

codecov Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.96970% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.24%. Comparing base (9f8bc62) to head (5f39751).

Files with missing lines Patch % Lines
internal/block/writer_buffer_pool.go 96.96% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5273      +/-   ##
==========================================
+ Coverage   85.19%   85.24%   +0.04%     
==========================================
  Files         181      182       +1     
  Lines       19957    20023      +66     
==========================================
+ Hits        17003    17068      +65     
- Misses       2953     2954       +1     
  Partials        1        1              
Flag Coverage Δ
unittests 85.24% <96.96%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
@vipnydav
vipnydav force-pushed the parallel-upload/writer-buffer-pool branch from 1e5fed8 to 5f39751 Compare November 23, 2026 08:57
@vipnydav vipnydav added the execute-integration-tests Run only integration tests label Nov 24, 2026
@github-actions

Copy link
Copy Markdown

Hi @kislaykishore, @vadlakondaswetha, your feedback is needed to move this pull request forward. This automated reminder was triggered because there has been no activity for over 24 hours. Please provide your input when you have a moment. Thank you!

3 similar comments
@github-actions

Copy link
Copy Markdown

Hi @kislaykishore, @vadlakondaswetha, your feedback is needed to move this pull request forward. This automated reminder was triggered because there has been no activity for over 24 hours. Please provide your input when you have a moment. Thank you!

@github-actions

Copy link
Copy Markdown

Hi @kislaykishore, @vadlakondaswetha, your feedback is needed to move this pull request forward. This automated reminder was triggered because there has been no activity for over 24 hours. Please provide your input when you have a moment. Thank you!

@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown

Hi @kislaykishore, @vadlakondaswetha, your feedback is needed to move this pull request forward. This automated reminder was triggered because there has been no activity for over 24 hours. Please provide your input when you have a moment. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

execute-integration-tests Run only integration tests remind-reviewers Auto remind reviewers in attention set for review post 24hrs of inactivity on PR.

1 participant