feat: replace CountMinSketch with FastFrequencySketch in Artery compression#3023
Open
He-Pin wants to merge 1 commit into
Open
feat: replace CountMinSketch with FastFrequencySketch in Artery compression#3023He-Pin wants to merge 1 commit into
He-Pin wants to merge 1 commit into
Conversation
pjfanning
reviewed
May 31, 2026
Member
|
I'd prefer if the old code was kept and made configurable - as in let user choose the compression scheme |
He-Pin
added a commit
that referenced
this pull request
May 31, 2026
Motivation: Reviewer (pjfanning) requested keeping the original CountMinSketch code and making the compression scheme configurable so users can choose. Modification: - Restored CountMinSketch.java (was deleted in previous commit) - Restored legal files for CountMinSketch attribution - Added configuration option to choose between 'count-min-sketch' and 'fast-frequency-sketch' (default) - Created FrequencySketch abstraction trait with wrappers for both CountMinSketch and FastFrequencySketch - Reverted CountMinSketchBenchmark to use CountMinSketch directly (FastFrequencySketch is private[pekko] and not accessible from bench-jmh) - Removed MiMa filter since CountMinSketch is no longer removed Result: Users can now choose between CountMinSketch (legacy, ~128KB per connection) and FastFrequencySketch (default, ~4KB per connection with TinyLFU aging). Tests: - remote/testOnly ...HeavyHittersSpec: 13/13 passed - remote/testOnly ...CompressionTableSpec: 3/3 passed - remote/compile: passed - bench-jmh/compile: passed - remote/mimaReportBinaryIssues: passed Refs: #3023
be77b6e to
83cd9ae
Compare
pjfanning
reviewed
Jun 16, 2026
2bfe105 to
eb1fd14
Compare
…ession Motivation: The Artery compression system uses a CountMinSketch (128KB per connection, 16x1024x8 bytes) for heavy hitter detection in actor ref and class manifest compression tables. Pekko already has FastFrequencySketch in pekko-actor (used for cluster sharding entity passivation) which is ~32x more memory efficient (~4KB vs ~128KB per inbound connection), includes TinyLFU reset for natural aging, and is already battle-tested in production. This addresses akka/akka-core#31093. Modification: - InboundCompressions.scala: Add configurable frequency-sketch-implementation setting supporting both "fast-frequency-sketch" (default) and "count-min-sketch" (legacy). Introduce FrequencySketch trait with CountMinSketchFrequencySketch and FastFrequencySketchWrapper implementations. InboundCompression uses the configured sketch for heavy hitter detection. - TopHeavyHitters.scala: update() always allows weight updates for existing heavy hitters (necessary for FrequencySketch periodic reset). updateExistingHeavyHitter() supports both weight increase (push down) and decrease (bubble up) in the heap. New fixHeapUp() method for bidirectional heap property restoration. isHeavy() check only gates insertion of new entries. - CountMinSketch.java: Kept as legacy option, wrapped via CountMinSketchFrequencySketch adapter. - CountMinSketchBenchmark.scala: Updated to benchmark both implementations. - reference.conf: Added frequency-sketch-implementation config with "fast-frequency-sketch" as default. - CompressionIntegrationSpec: Added integration test verifying compression works with count-min-sketch implementation. Result: Artery compression uses ~4KB instead of ~128KB per inbound connection by default. Heavy hitters adapt to changing traffic patterns via TinyLFU aging. Legacy CountMinSketch remains available via config. Tests: - remote/testOnly HeavyHittersSpec: 13/13 passed (includes 2 new tests) - remote/testOnly CompressionTableSpec: 3/3 passed - remote/testOnly OutboundCompressionSpec: 2/2 passed - remote/Test/compile: success (new CompressionIntegrationSpec test) References: Refs akka/akka-core#31093
eb1fd14 to
f6d81c2
Compare
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.
Motivation
The Artery compression system uses a
CountMinSketch(128KB per connection, 16×1024×8 bytes) for heavy hitter detection in actor ref and class manifest compression tables. Pekko already hasFastFrequencySketchinpekko-actor(used for cluster sharding entity passivation) which is:This addresses akka/akka-core#31093.
Modification
InboundCompressions.scala: ReplaceCountMinSketchwithFastFrequencySketch[T]inInboundCompression. Theincrementmethod now callsfrequencySketch.increment(value)per occurrence and usesfrequencySketch.frequency(value)as the estimated weight for heavy hitter detection.TopHeavyHitters.scala:update()now always allows weight updates for existing heavy hitters (previously only allowed increases). This is necessary becauseFrequencySketch's periodic reset halves all counters.updateExistingHeavyHitter()supports both weight increase (push down) and decrease (bubble up) in the heap.fixHeapUp()method for bidirectional heap property restoration.isHeavy()check now only gates insertion of new entries.CountMinSketch.java: Removed — wasINTERNAL APIwith no external users.CountMinSketchBenchmark.scala: Updated to benchmarkFastFrequencySketchinstead.Result
Artery compression uses ~4KB instead of ~128KB per inbound connection. Heavy hitters now adapt to changing traffic patterns via TinyLFU aging rather than tracking monotonically increasing absolute counts.
Tests
remote / testOnly ...HeavyHittersSpec: 13/13 passed (includes 2 new tests for weight decrease and heap upward restoration)remote / testOnly ...CompressionTableSpec: 3/3 passedremote / testOnly ...OutboundCompressionSpec: 2/2 passedReferences
Refs akka/akka-core#31093