Skip to content

server: guard disk KV cache with CRC32C#146

Open
Ghatage wants to merge 1 commit into
antirez:mainfrom
Ghatage:crc32c-disk-kv-cache
Open

server: guard disk KV cache with CRC32C#146
Ghatage wants to merge 1 commit into
antirez:mainfrom
Ghatage:crc32c-disk-kv-cache

Conversation

@Ghatage
Copy link
Copy Markdown
Contributor

@Ghatage Ghatage commented May 14, 2026

bad disk snapshots are rejected before session state is restored, while existing v1 caches stay readable.

Write new KV cache files as v2 with CRC32C for header metadata, rendered text, DS4 payload, and tool map. Keep v1 reads and touches intact, and recompute v2 CRCs when hit counts or tool maps are rewritten.

Reject corrupt v2 entries during load and same-text compatibility checks. A broken cache file is unlinked and replaced by a fresh write.

Correctness: git diff --check; CPU-built ./ds4_test --server.
Correctness: non-CPU tests/ds4_test.c object compile.

Benefit: bad disk snapshots are rejected before session state is restored, while existing v1 caches stay readable.

Write new KV cache files as v2 with CRC32C for header metadata, rendered text, DS4 payload, and tool map.
Keep v1 reads and touches intact, and recompute v2 CRCs when hit counts or tool maps are rewritten.

Reject corrupt v2 entries during load and same-text compatibility checks.
A broken cache file is unlinked and replaced by a fresh write.

Correctness: git diff --check; CPU-built ./ds4_test --server.
Correctness: non-CPU tests/ds4_test.c object compile.
@Ghatage Ghatage force-pushed the crc32c-disk-kv-cache branch from 0bfe4be to 0025dd3 Compare May 14, 2026 16:47
@ucjonathan
Copy link
Copy Markdown

Did something in DS4 write out a corrupt KV cache file or is this preventative in case that happens in the future?

@Ghatage
Copy link
Copy Markdown
Contributor Author

Ghatage commented May 14, 2026

ds4 did not corrupt anything... this is purely preventative.
Esp since now kv cache will be written to disk, checksums are table stakes to validate data integrity

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