Skip to content

Improving topic write buffer capacity accounting - #711

Open
Myllyenko wants to merge 1 commit into
ydb-platform:masterfrom
Myllyenko:codex/topic-writer-compression-accounting
Open

Improving topic write buffer capacity accounting#711
Myllyenko wants to merge 1 commit into
ydb-platform:masterfrom
Myllyenko:codex/topic-writer-compression-accounting

Conversation

@Myllyenko

Copy link
Copy Markdown

This PR minimizes probability of memory overconsumption in topic write sessions.

1. Reservation before compression

  • Old behavior: The writer reserved space based on the uncompressed input size. Compression framing and potential expansion were not considered during admission.
  • New behavior: The writer reserves space using the codec-provided encoded-size bound, capped at the configured buffer size.

2. Accounting for encoded-output expansion

  • Old behavior: When encoded output was larger than its original reservation, no additional permits were acquired. Buffer accounting continued to use the original reservation.
  • New behavior: After encoding, BufferManager#updateMessageSize attempts to account for as much of the actual encoded memory as current capacity permits without failing the message:
    • It acquires the complete additional reservation when enough permits are available.
    • Otherwise, it acquires all currently available permits.

@codecov

codecov Bot commented Aug 25, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.50000% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.42%. Comparing base (bc6886d) to head (b4d85ab).

Files with missing lines Patch % Lines
.../java/tech/ydb/topic/write/impl/BufferManager.java 78.57% 2 Missing and 1 partial ⚠️
...in/java/tech/ydb/topic/write/impl/WriterQueue.java 92.30% 1 Missing and 1 partial ⚠️
...in/java/tech/ydb/topic/impl/ZstdBackwardCodec.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             master     #711   +/-   ##
=========================================
  Coverage     72.42%   72.42%           
- Complexity     3522     3529    +7     
=========================================
  Files           391      392    +1     
  Lines         16341    16368   +27     
  Branches       1702     1707    +5     
=========================================
+ Hits          11835    11855   +20     
- Misses         3867     3871    +4     
- Partials        639      642    +3     

☔ 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.

@Myllyenko
Myllyenko force-pushed the codex/topic-writer-compression-accounting branch from 26e9a36 to b4d85ab Compare August 25, 2026 18:52
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.

1 participant