Skip to content

[improve][ml] Migrate managed-ledger from protobuf to LightProto#25336

Open
merlimat wants to merge 9 commits intoapache:masterfrom
merlimat:lp-managed-ledger-reuse
Open

[improve][ml] Migrate managed-ledger from protobuf to LightProto#25336
merlimat wants to merge 9 commits intoapache:masterfrom
merlimat:lp-managed-ledger-reuse

Conversation

@merlimat
Copy link
Contributor

Motivation

Migrate the managed-ledger module from Google protobuf to LightProto for
ManagedLedgerInfo and ManagedCursorInfo proto messages. LightProto generates
mutable, allocation-friendly Java classes with the same wire format, reducing GC
pressure on hot paths.

Modifications

  • Replace protobuf Builder pattern with direct LightProto mutable objects
  • Replace ByteString with byte[] for bytes fields
  • Replace static parseFrom() with instance parseFrom(ByteBuf, size)
  • Reuse LightProto objects in ManagedCursorImpl and MetaStoreImpl to
    reduce allocations on hot paths
  • Use indexed loops (getXxxCount() + getXxxAt(i)) for repeated fields
    instead of getXxxList() to avoid list copy overhead
  • Update all test files to use LightProto API

Documentation

  • doc-not-needed

Matching PR in forked repository

No response


Note

This PR depends on #25332 (Upgrade LightProto to 0.6.1)

  • ready-to-test

Migrate the managed-ledger module from Google protobuf to LightProto for
ManagedLedgerInfo and ManagedCursorInfo proto messages.

Key changes:
- Replace protobuf Builder pattern with direct LightProto mutable objects
- Replace ByteString with byte[] for bytes fields
- Replace static parseFrom() with instance parseFrom(ByteBuf, size)
- Reuse LightProto objects in ManagedCursorImpl and MetaStoreImpl to
  reduce allocations on hot paths
- Use indexed loops (getXxxCount() + getXxxAt(i)) for repeated fields
  instead of getXxxList() to avoid list copy overhead
- Update all test files to use LightProto API
@merlimat merlimat force-pushed the lp-managed-ledger-reuse branch from 6e4b8e8 to add770a Compare March 17, 2026 16:13
@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Mar 17, 2026
…-ledger proto types

Update broker test files that referenced the removed MLDataFormats outer
class wrapper. Replace MLDataFormats.ManagedLedgerInfo with
ManagedLedgerInfo and convert LedgerInfo.newBuilder().build() to
new LedgerInfo() constructor pattern.
LightProto 0.6.2 fixes optional field behavior to return default
values instead of throwing exceptions, matching standard protobuf
behavior.
…tProto

The test was using reflection to call a private method with a List
parameter that no longer exists. Updated to use the public
recoverIndividualDeletedMessages(PositionInfo) method directly.
LightProto does not implement equals(), so compare serialized bytes
instead of object equality.
Compare serialized bytes instead of object equality since LightProto
does not implement equals(). Also call materialize() after parsing
from ByteBuf to ensure the data is fully deserialized before
releasing the buffer.
@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 81.88153% with 52 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.70%. Comparing base (be87cd9) to head (e321036).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
...kkeeper/mledger/impl/ManagedLedgerFactoryImpl.java 61.90% 15 Missing and 1 partial ⚠️
...che/bookkeeper/mledger/impl/ManagedCursorImpl.java 85.93% 8 Missing and 1 partial ⚠️
...che/bookkeeper/mledger/impl/ManagedLedgerImpl.java 87.50% 4 Missing and 4 partials ⚠️
.../apache/bookkeeper/mledger/impl/MetaStoreImpl.java 88.33% 7 Missing ⚠️
...keeper/mledger/impl/ReadOnlyManagedLedgerImpl.java 55.55% 4 Missing ⚠️
...okkeeper/mledger/impl/ShadowManagedLedgerImpl.java 66.66% 4 Missing ⚠️
...eper/mledger/impl/ManagedLedgerOfflineBacklog.java 0.00% 2 Missing ⚠️
...d/jcloud/impl/BlobStoreManagedLedgerOffloader.java 75.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff              @@
##             master   #25336       +/-   ##
=============================================
+ Coverage     37.37%   72.70%   +35.32%     
+ Complexity    13188     2460    -10728     
=============================================
  Files          1897     1954       +57     
  Lines        150557   154775     +4218     
  Branches      17215    17720      +505     
=============================================
+ Hits          56276   112530    +56254     
+ Misses        86612    33213    -53399     
- Partials       7669     9032     +1363     
Flag Coverage Δ
inttests 25.86% <26.44%> (+0.07%) ⬆️
systests 22.53% <31.52%> (+0.06%) ⬆️
unittests 73.67% <79.44%> (+39.52%) ⬆️

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

Files with missing lines Coverage Δ
...org/apache/bookkeeper/mledger/LedgerOffloader.java 72.22% <ø> (+66.66%) ⬆️
...a/org/apache/bookkeeper/mledger/ManagedLedger.java 14.28% <ø> (+14.28%) ⬆️
...bookkeeper/mledger/ManagedLedgerFactoryConfig.java 100.00% <ø> (ø)
.../bookkeeper/mledger/MetadataCompressionConfig.java 100.00% <100.00%> (+36.36%) ⬆️
...e/bookkeeper/mledger/impl/EntryCountEstimator.java 92.85% <100.00%> (+35.71%) ⬆️
.../org/apache/bookkeeper/mledger/impl/MetaStore.java 100.00% <ø> (ø)
...he/bookkeeper/mledger/impl/ReadOnlyCursorImpl.java 95.83% <ø> (+95.83%) ⬆️
...pache/bookkeeper/mledger/offload/OffloadUtils.java 76.85% <100.00%> (+11.08%) ⬆️
...che/pulsar/broker/service/BacklogQuotaManager.java 63.23% <100.00%> (+55.14%) ⬆️
...ice/persistent/PersistentMessageExpiryMonitor.java 64.17% <100.00%> (+32.08%) ⬆️
... and 13 more

... and 1397 files with indirect coverage changes

🚀 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

doc-not-needed Your PR changes do not impact docs ready-to-test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants