Skip to content

Add Zstd compression support and fix compression ratio metric bug#194

Open
janewang1680 wants to merge 9 commits into
Netflix:masterfrom
janewang1680:feat/compression-algorithm-enum
Open

Add Zstd compression support and fix compression ratio metric bug#194
janewang1680 wants to merge 9 commits into
Netflix:masterfrom
janewang1680:feat/compression-algorithm-enum

Conversation

@janewang1680
Copy link
Copy Markdown

@janewang1680 janewang1680 commented May 18, 2026

[Coda page] (https://coda.io/d/EVCache-Zstd-Support_dMpMIEBGnG5/EVCache-Zstd-Support_survVvtu#_luv_j_Y4)

Summary

  • Add pluggable compression algorithm support (gzip, zstd) via a new CompressionAlgorithm enum on EVCacheSerializingTranscoder, with magic-byte auto-detection on decode so existing gzip-compressed cache entries
    continue to decode correctly. Algorithm and zstd level are configurable via two new fast properties:
    • default.evcache.compression.algorithm (default GZIP)
    • default.evcache.compression.zstd.level (default 3)
  • Fix a pre-existing bug in the compression ratio metric where compressed.length / b.length always evaluated to 1.0 because b was reassigned to compressed before the ratio calculation. The metric now uses the
    captured originalLength, producing accurate ratios.

Test plan

  • ./gradlew :evcache-core:test --tests "com.netflix.evcache.EVCacheSerializingTranscoderTest" — 17 tests covering enum values, default constructor, gzip/zstd round-trip, cross-decode (gzip-written read by zstd
    transcoder and vice versa), and FP wiring.
  • Verify backward compatibility: data written with gzip in production decodes correctly after deploy.
  • Verify compression ratio metric (COMPRESSION_RATIO timer) reports realistic ratios (not always ~100%) in a canary.

Jane Wang and others added 9 commits May 16, 2026 10:00
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds CompressionAlgorithm enum (GZIP, ZSTD) to EVCacheSerializingTranscoder
with magic-byte auto-detection on decode for full backward compatibility.
EVCacheTranscoder wires algorithm and zstd level from Fast Properties.
Fixes compression ratio metric which was always reporting 100%.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Fix decompress() to always delegate non-zstd data to super (removes
redundant gzip magic-byte check). Add three EVCacheTranscoder FP tests
that inject a fresh DefaultSettableConfig per test to avoid Archaius
property caching between test runs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant