Skip to content

searcher: derive cache size from any Kubernetes quantity via shared parser - #965

Merged
marcleblanc2 merged 1 commit into
searcher-storagesize-g-unitsfrom
searcher-storagesize-quantity
Oct 19, 2026
Merged

marcleblanc2 merged 1 commit into
searcher-storagesize-g-unitsfrom
searcher-storagesize-quantity

Conversation

@michaellzc

Copy link
Copy Markdown
Member

Follow-up to #948, targeting its branch so it can be merged into the same fix. #948's allowlist (M|Mi|G|Gi) turns 1Ti and other valid PVC sizes from "silently renders 0" into "helm upgrade refuses", and it can still render 0 for 0G/1M/2M, which searcher treats as "never evict".

This extracts the Kubernetes quantity parser that sourcegraph.redis.maxmemory already had into a shared sourcegraph.quantityBytes helper and uses it for searcher.storageSize, so any quantity (1Ti, 1.5G, 1024Ki, suffixless bytes) works and the parser is defined once. The 45% is computed the way searcher auto-sizes (floor(bytes/1e6) * 45 / 100) instead of treating Gi as G, and the render fails when the result would be 0. Behaviour change to be aware of: existing Gi deployments get a slightly higher value on upgrade (default 26Gi: 11700 → 12562), called out in the CHANGELOG.

Test plan

helm unittest charts/sourcegraph (195 passed, incl. the unchanged Redis maxmemory suite covering the extracted parser), helm lint, ./scripts/helm-docs.sh clean.

searcher.storageSize main #948 this PR
26Gi (default) 11700 11700 12562
150G 0 67500 67500
1Ti 0 render fails 494779
1.5G 0 render fails 675
2M / 0G 0 0 render fails
1Tb 0 render fails render fails
1Tb + autoCacheSize: true omitted omitted omitted

…arser

Extract the quantity parser from sourcegraph.redis.maxmemory into
sourcegraph.quantityBytes and use it for searcher.storageSize too, so Ti,
Ki, fractional and suffixless values work instead of failing the render.
Compute 45% the same way searcher auto-sizes (floor(bytes/1e6)*45/100)
rather than treating Gi as G, and fail when the result would be 0, since
an explicit 0 disables eviction.

Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-01a14718-43f2-75ab-b1b7-f2ed264868db
@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

@marcleblanc2
marcleblanc2 merged commit 38f0613 into searcher-storagesize-g-units Oct 19, 2026
4 checks passed
@marcleblanc2
marcleblanc2 deleted the searcher-storagesize-quantity branch October 19, 2026 19:49
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