pjfanning opened a new pull request, #3484:
URL: https://github.com/apache/pekko/pull/3484

   Motivation:
   #3425 introduced a `Set` as the collection of accepted TCP magic values. 
Sets default to `HashSet`, which hashes its members, and hashing a `ByteString` 
walks every one of its bytes. Comparing this handful of 4-byte values is better 
done with a couple of equality checks over a small ordered collection.
   
   Modification:
   Change `ArterySettings.Advanced.TcpMagicValues` from `Set[ByteString]` to 
`immutable.Seq[ByteString]`, built with `distinct.toList` rather than `toSet` 
so the de-duplication the `Set` provided incidentally is kept, and change the 
`TcpFraming` `acceptedMagic` parameter to match. These were the only two 
`Set[ByteString]` in the tree; both are `private[pekko]` and both arrived in 
#3425.
   
   Add `ArterySettingsSpec`, which did not exist: the `tcp-magic` parsing added 
by #3425 had no direct test.
   
   Result:
   `TcpFraming`'s magic check on each inbound connection is a small number of 
`ByteString` equality comparisons instead of a `hashCode` over the received 
bytes.
   
   One semantic change worth calling out: acceptance order is now the 
configured order, where the `Set` left it unspecified. This is consistent with 
`TcpMagic`, the outbound magic, already being the first configured value. No 
other behaviour changes.
   
   Tests:
   - `sbt "remote/testOnly org.apache.pekko.remote.artery.ArterySettingsSpec"` 
- 7 tests succeeded, 0 failed
   - `sbt "remote/testOnly org.apache.pekko.remote.artery.tcp.TcpFramingSpec"` 
- 11 tests succeeded, 0 failed, covering the default, custom and legacy `AKKA` 
magic paths through the changed `contains` call
   - `sbt "remote/mimaReportBinaryIssues"` - no issues, no filters needed
   - `ArterySettingsSpec` pins the configuration order, the de-duplication 
including after 4-byte truncation, and both `require` rejections, so the 
collection type cannot be changed back without a failure.
   
   References:
   Fixes #3483, Refs #3425
   
   Still to follow: a backport to 1.7.x, since #3425 is in 1.7.0 and that 
branch does not have the faster `ByteString.equals` from main.


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to