Repository navigation
Conversation
Motivation: apache#3727 opted the GraphStage TLS engine's input boundaries out of sender-side batching so plaintext is not overtaken by a later plaintext-output cancellation. The opt-out applied to every input boundary of the TLS island, so ciphertext input from the transport also crossed the async boundary as one actor message per element, although it has no such ordering constraint. Modification: - UnbatchedInput now names the inlets it applies to. The materializer marks a BatchingActorInputBoundary unbatched only when the inlet it feeds is listed. - TlsGraphStage lists only its plaintext input inlet. Result: Plaintext input keeps the apache#3727 ordering guarantee; ciphertext input is batched across the async boundary again. Tests: - stream-tests/testOnly TlsGraphStageIsolatedSpec -z "batch transport input": passes; fails with cipherIn added back to UnbatchedInput (false was not equal to true) - stream-tests/testOnly org.apache.pekko.stream.io.Tls*: 286 passed - stream/mimaReportBinaryIssues: no issues - scalafmt --mode diff-ref=upstream/main: clean References: Refs apache#3727
|
Quick JMH run of
This does not show an improvement. The error bars overlap everywhere, but the baseline is nominally faster at 256 B and 4 KiB (4 KiB iterations: 15–27 ops/ms here vs 24–46 baseline), and 64 KiB is flat. One fork, short iterations and a laptop make this noisy, and the two variants ran sequentially rather than interleaved, so it isn't conclusive either way. This benchmark is also round-trip/echo shaped, where batches are often a single element; it doesn't model bulk inbound transfer. I'd treat the perf benefit of this PR as unproven until a longer run (more forks, interleaved variants) or a bulk-inbound benchmark shows it. |
|
Follow-up JMH run with more forks and interleaved variants, addressing the caveats in my previous comment. Setup. Both variants are in one JMH invocation through a temporary (uncommitted)
4 rounds of Score per round (ops/ms, higher is better):
Difference within each round (this PR vs main):
Reading:
So on this echo/round-trip benchmark, batching ciphertext input does not help, and at 4 KiB it costs a few percent. A plausible cause is that in a ping-pong exchange, batches are usually one element, so batching adds bookkeeping without saving messages. This benchmark does not model bulk inbound transfer, where batching could still pay off, but there is no evidence for that yet. I'd not merge this as a performance change on the current evidence. |
|
Closing: the interleaved JMH runs show no throughput gain from batching TLS ciphertext input (and a small regression at 4 KiB). Plaintext ordering relative to cancellation is already handled on main. |
Motivation
#3727 opted the GraphStage TLS engine's input boundaries out of sender-side batching so plaintext is not overtaken by a later plaintext-output cancellation. The opt-out (
UnbatchedInput) was checked against the TLS stage's attributes, which every input boundary of the TLS island inherits. So ciphertext input from the transport also crossed the async boundary as one actor message per element, although it has no such ordering constraint and it is the hot inbound path.Modification
UnbatchedInputnow names the inlets it applies to. InGraphStageIsland.takePublisher, the materializer marks aBatchingActorInputBoundaryunbatched only when the inlet it feeds is listed.ActorOutputBoundarychecks that flag instead of the attribute.TlsGraphStage.StreamTlsAttributeslists only the plaintext input inlet.ActorOutputBoundary.batchesToSubscriber(private[stream]) exposes the chosen mode for the test.Result
Plaintext input keeps the #3727 ordering guarantee. Ciphertext input is batched across the async boundary again.
Tests
stream-tests/testOnly org.apache.pekko.stream.io.TlsGraphStageIsolatedSpec -- -z "batch transport input": new test, passes. It runs a realTlsGraphStageand checks the mode chosen by the output boundary in front of each inlet. It fails whencipherInis added back toUnbatchedInput(false was not equal to trueon the ciphertext assertion).stream-tests/testOnly org.apache.pekko.stream.io.Tls*: 11 suites, 286 tests passedstream/mimaReportBinaryIssues: no issues (UnbatchedInputis internal and unreleased)scalafmt --mode diff-ref=upstream/main: cleanReferences
Refs #3727