Skip to content

Move binary serialization to EVCacheSerializingTranscoder Refactor#200

Open
joegoogle123 wants to merge 1 commit into
masterfrom
joelee/refactor-move-binary-serde
Open

Move binary serialization to EVCacheSerializingTranscoder Refactor#200
joegoogle123 wants to merge 1 commit into
masterfrom
joelee/refactor-move-binary-serde

Conversation

@joegoogle123

Copy link
Copy Markdown
Contributor

Summary

Follow-up refactor to PR #196. Moves the EVCacheValue binary serde dispatch onto the superclass and cleans up the transcoder properties API so callers get typed accessors instead of the generic getProperty(Key, Class, T) escape hatch.

Zero behavior change on the wire — the same serialize/deserialize gating and EVCacheValueSerde.isBinaryFormat check just live one class up. This lands ahead of the zstd compression PR (#197) so that PR shows only compression content.

What changed

  • EVCacheSerializingTranscoder — added protected serialize/deserialize overrides that gate on transcoderProperties.isBinarySerializationEnabled() && o instanceof EVCacheValue (moved from EVCacheTranscoder). Constructor reordered to (int max, EVCacheTranscoderProperties). New protected final String appName field pulled from properties.getAppName() for downstream metric tagging. Renamed propertiestranscoderProperties. Removed unused imports (ServerGroup, StringUtils, Map, ConcurrentHashMap).
  • EVCacheTranscoder — now a thin wrapper: only encode() overrides super (to pass CachedData through unchanged). Removed the redundant asyncDecode/decode overrides that only delegated. Constructors updated to use typed getters and the new super signature.
  • EVCacheTranscoderProperties — snapshotted maxDataSizeBytes and compressionThresholdBytes as final int at construction. Added typed getters getAppName(), getMaxDataSizeBytes(), getCompressionThresholdBytes(). Removed the public <T> Property<T> getProperty(Key, Class, T) method — no callers remain now that the transcoder chain uses the typed accessors.
  • BaseAsciiConnectionFactory / BaseConnectionFactorygetDefaultTranscoder() now passes a per-app EVCacheTranscoderProperties bundle so the <appName>.<key> prefix reaches the default transcoder path. PR EVCacheValue: opt-in compact binary serialization with backwards-compatible reads #196 wired this for the value transcoder in EVCacheImpl but missed the default transcoder built here.
  • EVCacheTranscoderPropertiesTest — 15 existing resolution-chain cases migrated to the typed getters. Added 2 cases for getAppName().

Test plan

  • ./gradlew :evcache-core:test --tests "com.netflix.evcache.config.EVCacheTranscoderPropertiesTest" — 17/17 pass
  • ./gradlew :evcache-core:test --tests "com.netflix.evcache.pool.EVCacheValueSerdeTest" — 17/17 pass (dispatch coverage from PR EVCacheValue: opt-in compact binary serialization with backwards-compatible reads #196 still green since the dispatch just moved up a class)
  • ./gradlew :evcache-core:build — clean, no unused-import warnings

🤖 Generated with Claude Code

Refactor PR #196's binary-serde plumbing so the EVCacheValue dispatch
lives on the superclass and callers get typed accessors instead of the
generic getProperty escape hatch.

- Move the serialize/deserialize overrides that gate on
  isBinarySerializationEnabled + EVCacheValueSerde.isBinaryFormat from
  EVCacheTranscoder up to EVCacheSerializingTranscoder. The subclass is
  now a thin wrapper: only encode() still overrides super to pass
  CachedData through unchanged.
- Drop the trivial asyncDecode/decode overrides on EVCacheTranscoder
  that only delegated to super.
- Reorder the EVCacheSerializingTranscoder constructor to
  (int max, EVCacheTranscoderProperties). Rename the properties field
  to transcoderProperties. Subclasses that need appName read it from
  transcoderProperties.getAppName() rather than a dedicated field.
- On EVCacheTranscoderProperties, snapshot maxDataSizeBytes and
  compressionThresholdBytes as primitives at construction and expose
  them via typed getters (getMaxDataSizeBytes, getCompressionThresholdBytes,
  getAppName). Drop the public getProperty(Key, Class, T) escape hatch;
  no callers remain now that the transcoder chain uses the typed
  accessors. Dynamic fields will be exposed as Property<T> accessors.
- Wire the connection factories' getDefaultTranscoder() through a
  per-app EVCacheTranscoderProperties so the per-app FP prefix reaches
  the default transcoder path — PR #196 wired this for the value
  transcoder but missed the default transcoder built here.
- Delete unused imports (ServerGroup, StringUtils, Map, ConcurrentHashMap)
  left behind on EVCacheSerializingTranscoder.

Test coverage in EVCacheTranscoderPropertiesTest is migrated to the
typed getters and extended with two cases for getAppName. Existing
resolution-chain cases (per-app → global → static default) are preserved.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@joegoogle123 joegoogle123 force-pushed the joelee/refactor-move-binary-serde branch from e72af3f to 45d17db Compare July 8, 2026 20:23
@joegoogle123

Copy link
Copy Markdown
Contributor Author

@janewang1680 once this merges you can rebase off of this for your compression PR.

* <p>
* Static properties should be cached as a field for fast access.
* Dynamic properties get be accessed {@link #getProperty(Key, Class, Object)}
* Static properties are snapshotted as primitive fields for fast access. Dynamic fields

@shy-1234 shy-1234 Jul 8, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a blocker since it's the original behavior, but just curious how much overhead would it be to also make those static properties dynamic? (I think the dynamic values are also cached?)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are two fields that where static e.g max and compressionThreshold which I don't think we can make dynamic.

There is a new field to binarySerializationEnabled which we could make dynamic but I did not measure the overhead of dynamically checking this property.

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.

2 participants