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

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

Conversation

@Myllyenko

@Myllyenko Myllyenko commented Aug 25, 2026

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.

    When the full reservation cannot be acquired, a warning reports that the configured buffer size may be temporarily exceeded. updateMessageSize now returns the effective reservation instead of void.

@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 73.16%. Comparing base (d77889d) to head (7fe40a3).

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     73.18%   73.16%   -0.03%     
- Complexity     3589     3599      +10     
============================================
  Files           392      393       +1     
  Lines         16531    16558      +27     
  Branches       1736     1741       +5     
============================================
+ Hits          12099    12115      +16     
- Misses         3811     3819       +8     
- Partials        621      624       +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
@Myllyenko
Myllyenko force-pushed the codex/topic-writer-compression-accounting branch from b4d85ab to 7fe40a3 Compare September 17, 2026 13:54
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