Keep the send callback scalar-replaceable: drop the volatile flag - #21
Merged
Conversation
The synchronous-failure flag of SendCallback is a plain field. Its only concurrent writer is an asynchronous error callback racing the read after send() returns, and both outcomes of that race are correct (fallback-only or dispatched-plus-later-fallback), so the volatile bought a guarantee no reader needs - and pinned the callback object against C2's scalar replacement wherever the client does not retain it (+48 B/op on the SenderPathBenchmark unbound path since 1c8b048). Acceptance check per the benchmark report's protocol (3 forks, 5+5 iterations, -prof gc), raw output under benchmarks/results/2026-09-07: unbound 112.000 B/op - the 2026-08-30 baseline restored. The metrics-bound variant reads 224 B/op, but so does the pre-change code 6c4f2b8 measured on the same JVM in the same session (control file), i.e. JIT-profile variance the report already documents, not a code effect. A value-forwarding onCompletion was tried against it and reverted as measurably neutral. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015GfdGp7eUrjJKBvcJUx3q2
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.
Follow-up to the benchmark validity check:
SenderPathBenchmarkunbound had moved from 112 to 160 B/op since1c8b048(theSendCallbackclass). Cause, verified by experiment: the@VolatileonerrorReportedpins the callback object against C2's scalar replacement wherever the callback does not escape.Change
SendCallback.errorReportedis a plain field with aSafety:rationale: the only concurrent writer is an asynchronous error callback racing the read aftersend()returns, and both outcomes are correct (fallback-only, or dispatched plus the latersend.errorfallback). Production semantics unchanged; with the realKafkaProducerthe callback escapes into the batch either way.SenderPathBenchmarkKDoc notes the scalar-replaceability guard; changelog entry.Acceptance check (benchmark report protocol: 3 forks, 5+5 iterations,
-prof gc)6c4f2b8also reads 224 B/op on the same JVM in the same session (control file), i.e. JIT-profile variance, not a code effectRaw outputs under
benchmarks/results/2026-09-07/. A value-forwardingonCompletionwas tried against the bound-path difference and reverted as measurably neutral.mvn verify(offline, incl. ktlint): 269 tests green;dokka:dokkawithfailOnWarningpasses.🤖 Generated with Claude Code
https://claude.ai/code/session_015GfdGp7eUrjJKBvcJUx3q2