Repository navigation
perf(binding-kafka): claim a block in the log file for produce-path trailer entries - #2457
Merged
Merged
Conversation
…railer entries KafkaCacheTrailerEnvelope accumulated a composed transform's envelope.set() calls in a per-stream, heap-resident growable arena retained for the entire lifetime of the producing stream. The log file already solves an equivalent problem for a transformed value's own output with zero retained heap state: a worst-case block is reserved once per message (mirroring convertedFile's existing claim), and the transform writes directly into it. Apply the same claim-per-message approach to trailer entries: reserve a second, separate block per message (sized from the existing cache.client.trailers.size.max bound) right next to the block already reserved for the final merged trailers, and have KafkaCacheTrailerEnvelope write set() calls directly into it via a small write cursor instead of a growable arena. If a message's entries exceed the claimed block, the excess is dropped and the entry is marked aborted rather than completed, mirroring how a transformed value exceeding its own reservation is handled. Fixes #2456
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
KafkaCacheTrailerEnvelopeaccumulated a composed transform'sset()calls during produce-path encode in a per-stream, heap-resident growable arena (an expandable buffer plus parallel offset/length arrays), retained for the entire lifetime of the producing stream.The storage layer already solves an equivalent problem for a transformed value's own output with zero retained per-stream heap state:
KafkaCachePartitionreserves a worst-case-sized block once per message inconvertedFile, and the transform writes directly into that already-claimed block viaconsumeTransformed-- no heap buffer at all, just a couple of file positions tracked.This applies the same claim-per-message approach to trailer entries, but without introducing a new file: the log file already reserves a
cache.client.trailers.size.max-sized block per message for the final merged trailers (committed at FIN). This adds a second, separate claim of the same size, right next to it, for the envelope's own accumulation during encode.KafkaCacheTrailerEnvelopenow writesset()calls directly into that claimed block via a small write cursor, instead of a growable arena --count()/get()/writeHeaders()scan the claimed block directly. If a message's entries exceed the claimed block, the excess is dropped and the entry is marked aborted (mirroring how a transformed value exceeding its own reservation is handled) rather than corrupting anything or rejecting the whole record.Testing
KafkaCacheTrailerEnvelopeTestrewritten test-first for the claimed-slot design (against a realKafkaCacheFilebacked by a temp file), including new coverage for the overflow/abort case and forset()calls made before any claim.message.value.envelope.overflow,CacheProduceIT#shouldSendMessageValueEnvelopeOverflow) configuringcache.client.trailers.size.maxsmall enough to overflow on the second of two configured fields, proving the entry becomes invisible to the downstream relay (aborted) rather than corrupting or partially leaking data.message.value.envelope*scenarios (feat(binding-kafka): wire ModelEnvelope into kafka cache storage's read and write paths #2455) continue to pass unmodified -- only the envelope's internal storage changed, not its observable contract.runtime/binding-kafkamodule (clean verify): all unit tests, all k3po ITs, checkstyle, license, and jacoco coverage pass with no regressions.Fixes #2456
Generated by Claude Code