Commit 167a2a9
Lower post-candidate cache compression from zstd 6 to zstd 1
RedisPostCandidateCacheSideEffect compresses ~2 MB of serde_json on every
cache-miss For You request (MaxPostsToCache = 750 candidates, each a 54-field
PostCandidate). The payload is highly repetitive because all 750 share one
schema, so zstd's fast strategy already captures nearly all of the redundancy
and the higher levels buy very little.
Measured on a reconstructed 750-candidate slate, libzstd 1.5.7:
level bytes ms vs level 6
1 349,857 1.63 -6.0% size, 5.9x faster
2 379,683 2.51 +2.1% size, 3.9x faster
3 404,066 3.54 +8.6% size, 2.7x faster
6 372,017 9.72 (current)
9 354,442 14.22 -4.7% size, 0.7x
Levels 2-4 are both slower and larger than level 1 here, so this is not a
size/speed tradeoff: level 1 dominates them on both axes. Held across three
text-entropy models (24-word, 2000-word, random) and two seeds; level 1 stayed
within -6.0%/+2.0% of level 6 on size at 5.7-7.7x less CPU.
Since the entry only lives for REDIS_TTL_SECONDS = 180, request-path CPU
dominates the value of a marginally smaller blob.
zstd frames are self-describing and the cache key does not encode the
compression level, so CachedPostsQueryHydrator reads entries written by hosts
on either side of a rolling deploy. Added a regression test pinning that so the
level stays retunable.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent a389166 commit 167a2a9
1 file changed
Lines changed: 37 additions & 1 deletion
Lines changed: 37 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
12 | 21 | | |
13 | 22 | | |
14 | 23 | | |
| |||
211 | 220 | | |
212 | 221 | | |
213 | 222 | | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
214 | 250 | | |
215 | 251 | | |
216 | 252 | | |
| |||
0 commit comments