Repository navigation
feat(redis): write with the policy serializer and read values by format header - #404
Open
cosmin-staicu wants to merge 1 commit into
Open
cosmin-staicu wants to merge 1 commit into
cosmin-staicu wants to merge 1 commit into
Conversation
cosmin-staicu
requested review from
alinahornet,
florin-munteanu-uipath,
litheon,
lucianaparaschivei and
razvalex
as code owners
November 11, 2026 22:53
|
🔎 Maintainer heads-up: automated triage flagged this PR as potentially material, so it may need a signed CLA in addition to the DCO sign-off. Other signals
This is advisory only — the bot does not decide. Please judge against the CLA criteria (material, product-critical, patent-sensitive, corporate contributor, broad commercial use). Note that thresholds can be gamed by splitting PRs, so use your judgement.
|
cosmin-staicu
force-pushed
the
perf/value-serializer-seam
branch
3 times, most recently
from
November 13, 2026 13:32
869bbe1 to
4dc0508
Compare
cosmin-staicu
force-pushed
the
perf/value-serializer-wiring
branch
from
November 13, 2026 13:39
9c17a18 to
e368986
Compare
cosmin-staicu
force-pushed
the
perf/value-serializer-seam
branch
from
November 13, 2026 13:44
4dc0508 to
8ff5729
Compare
cosmin-staicu
force-pushed
the
perf/value-serializer-wiring
branch
4 times, most recently
from
November 14, 2026 03:46
9378c89 to
f4a9d49
Compare
RedisCache and RedisHashCache now write with the policy's serializer and read every value by its format header. A policy naming "json" or no serializer keeps the original headerless JSON path. A registered name writes the format id followed by the payload through the pooled writer, and an unregistered name throws InvalidOperationException before anything is written, including for ad-hoc and custom-factory policies. When a serializer is registered, a read checks the first byte. JSON is read as before and a known format id goes to its serializer. An unknown id counts as a miss and the key is deleted only if it still holds the bytes that were read, so a value another node just wrote is not removed. A serializer that throws is a miss and the key is kept, as a JSON failure is today. Raw byte[] proxies are sniffed only when the effective write is a non-JSON serializer. Hash caches follow the same rule for fields, metadata and peer fields. An unreadable hash is a miss and is never deleted, and system field names are compared as bytes. Serializer.Read is validated but does not limit reads yet, MigrateOnRead is accepted but not acted on, and AddDistributedCache stays on JSON. An app that registers no serializer sees no change. Once a non-JSON format is written, every node reading those keys must run this version, so read-capable nodes should be deployed first. Signed-off-by: Cosmin Staicu <cosmin.staicu@uipath.com>
cosmin-staicu
force-pushed
the
perf/value-serializer-wiring
branch
from
November 14, 2026 04:17
f4a9d49 to
a32ea16
Compare
|
This branch has not been deployed
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.



Summary
Third in the fast value serializer stack, on top of #403.
RedisCacheandRedisHashCachenow write with the policy's serializer and read every value by its format header.The narrower removal rule is deliberate. Removing on every read failure could delete a value another node had just written, or wipe good data during a rolling type change.
Serializer.Readis validated but does not yet limit reads, andMigrateOnReadis accepted but not acted on. Both land with online migration later in the stack.AddDistributedCachestays on JSON.Evidence
JSON default path allocates exactly what the base allocates (BenchmarkDotNet, fake connector, no registry):
State machine field layouts were diffed against the base and are identical. With a registry present, a sniffing read costs Get +16 B and GetOrAdd +32 B.
Round trip through a registered serializer picked by
Serializer.Write, assertingSerializeandDeserializeare called, in unit tests and against Redis.Mutations caught: sniff gate widened to raw proxies, sniff gate opened by
Write="json"(any casing), null slot written as JSON, blind orKeyExistsdelete instead of the value-equal condition, a throwing serializer treated as unreadable,OutOfMemoryExceptionswallowed, system field compared by length, peer decode without sniffing,_version_treated as a user field, telemetry method names changed, no per-field fallback to the default policy's serializer, peer-field gate taken from the default policy instead of the key's, stale_metadata_deleted outside the replace transaction,OutOfMemoryExceptionswallowed by the public reads.Telemetry
Methodnames are the same as before on every operation.A leased read was measured and dropped: less allocation, no measurable latency win. Only its benchmark is kept.
Full suite with Redis: 4895, 0 failed, 1 skipped (a pre-Redis-7 case on Redis 7.4), including concurrent-write races on the conditional delete.
-c Release -warnaserrorbuilds clean.Merge Danger
Door: one-way once a non-JSON serializer is used
Nothing changes for an app that registers no serializer. Once an app writes a non-JSON format, every node that reads those keys must run this version, so the rolling deploy order matters (read-capable nodes first).
docs/how-to/extending.mddescribes it.Blast Radius: storage
Every Redis read and write. The default path is byte-for-byte and allocation-for-allocation the same.