You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "lhotari (via GitHub)" <gi...@apache.org> on 2026/09/10 12:36:00 UTC
[PR] [improve][client] Avoid eager broker metadata allocation for outgoing messages [pulsar]
lhotari opened a new pull request, #26521:
URL: https://github.com/apache/pulsar/pull/26521
### Motivation
The `MessageImpl` recycler constructor eagerly allocates `BrokerEntryMetadata` for outgoing messages, although those messages do not yet have broker-added timestamp or index information. This creates an unused object whenever a fresh `MessageImpl` is allocated.
### Modifications
Remove that constructor allocation, leaving the field null until metadata is supplied. Existing timestamp/index accessors already handle null, and incoming deserialization supplies parsed metadata. Add coverage for absent metadata, explicitly assigned timestamp/index values, and absence after recycling followed by message creation. Include a focused outgoing-message construction benchmark.
### Verifying this change
Prior Linux x86_64 / Corretto 25 / ZGC JMH measurements showed **608 → 552 B per fresh message**, saving **56 B**, and approximately 8.6% less construction time. The benchmark excludes builder allocation, serialization and networking. Both ordinary-worker modes allocate fresh messages even when `recycle()` is called; already-reused instances do not incur this constructor cost. These are historical experiment results, not new measurements of the extracted branch or a throughput claim.
Local extraction validation passed: all required Spotless and main/test Checkstyle checks, 43 message/builder/broker-metadata test cases with zero failures or skips, and benchmark compilation.
```shell
./gradlew spotlessCheck checkstyleMain checkstyleTest \
:pulsar-client-original:test \
--tests org.apache.pulsar.client.impl.MessageImplTest \
--tests org.apache.pulsar.client.impl.TypedMessageBuilderImplTest \
:pulsar-broker:test \
--tests org.apache.pulsar.broker.service.BrokerEntryMetadataE2ETest \
:microbench:compileJava -PtestRetryCount=0 --max-workers=2 --no-parallel
```
The lifecycle test does not assume that ordinary test threads retrieve the same pooled instance. Existing broker-metadata end-to-end tests cover parsed metadata behavior.
- [ ] Make sure that the change passes the CI checks.
### Does this pull request potentially affect one of the following parts:
- [ ] Dependencies (add or upgrade a dependency)
- [ ] The public API
- [ ] The schema
- [ ] The default values of configurations
- [ ] The threading model
- [ ] The binary protocol
- [ ] The REST endpoints
- [ ] The admin CLI options
- [ ] The metrics
- [ ] Anything that affects deployment
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [improve][client] Avoid eager broker metadata allocation for outgoing messages [pulsar]
Posted by "merlimat (via GitHub)" <gi...@apache.org>.
merlimat merged PR #26521:
URL: https://github.com/apache/pulsar/pull/26521
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org