afpd: a stock config gets the documented 64K dircache - #3264
Conversation
|
augment review |
|
Looks like you're out of credits for this review. Head to your account settings to top up and keep reviews running. https://app.augmentcode.com/account/subscription |
2c43468 to
1878605
Compare
An unset 'dircache size' resolved to DEFAULT_MAX_DIRCACHE_SIZE = 8192 (globals.h), a netatalk-2.x-era constant that predates the dircache rewrite, while dircache_init()'s own DEFAULT_DIRCACHE_SIZE, the man page, the docker image, and the webmin module all say 65536 -- two constants meaning "the default" drifted, and every stock install has run an 8x smaller cache than documented. Collapse the two into a single DEFAULT_DIRCACHE_SIZE in globals.h (which dircache.h already includes), so the default is defined once and cannot drift again. Extract dircache_init()'s size resolution into a pure helper so the bounds behaviour is unit-testable. Fix the stale size-formula comments and the webmin label/cap while touching the files.
1878605 to
bbe6a6a
Compare
|
@rdmark ready for review |
|
📊 Performance DashboardCommit: 🔥 Spectest (AFP 3.4) - FlameGraphNetatalk Code-time: 3.2% · Runtime: 59s · Stacks: 727 🔥 Click the preview to open the interactive flamegraph (zoom + search). 🔝 Top 10 leaf functions
📈 Speedtest (AFP 3.4) - PerfGraphPeak Read: 6387 MB/s (-11.7% vs hist avg 7233.9 MB/s; min 5963 / max 9526 over 26 PRs) 🔝 Throughputs per operation (vs. historical average)
⏱️ Lantest (AFP 3.4) - LatencyGraphAvg total runtime: 4432 ms (+3.5% vs hist avg 4282.9 ms; min 2412 / max 5208 over 26 PRs) 🐢 All operations (avg runtime, in test order, vs. historical average)
Run baseline: median op-test delta +11.6%, MAD 4.5%. Adj Δ% shifts each delta by the median; standouts ≥5% in bold. A large MAD means the run did not move uniformly — read the adjusted column with caution. |







Root cause
Two constants both mean "the dircache size default", and they drifted apart:
DEFAULT_DIRCACHE_SIZE = 65536inetc/afpd/dircache.h— whatdircache_init()applies, and what the man page, the docker image, and the webmin module all document.DEFAULT_MAX_DIRCACHE_SIZE = 8192ininclude/atalk/globals.h— what an unsetdircache sizeactually resolves to inafp_config_parse().Because 8192 is above the 1024 minimum,
dircache_init()accepted it verbatim — so every stock configuration has been running an 8× smaller directory cache than documented. Explicitdircache sizesettings were never affected.How the drift got here
dircache.h), but the config-side constant inglobals.hwas not part of that changeTwo constants meaning "the default" diverged, and nothing tied them together.
Defect → fix
DEFAULT_DIRCACHE_SIZE = 65536inglobals.h, whichdircache.halready includes — one definition, nothing to driftdircache_maxsizeis a static set insidedircache_init(), which also builds live cache state)dircache_resolve_size()helper;dircache_init()calls itmax(DEFAULT_DIRCACHE_SIZE, min(size, MAX_DIRCACHE_SIZE))— never the actual algorithm — and reference a nonexistentDIRCACHE_FREEDIRCACHE_FREE_QUANTUMMAX_DIRCACHE_SIZE(1048576)config_max:), inviting the same bytes-vs-entries misreadingconfig_max_entries:in both the ARC and LRU lines; lantest only matches the line prefix, so nothing parses the old label;doc/developer/dircache.mdfield list and examples updateddoc/developer/dircache.mdstill described the dircache as "by default just 8192 entries" — the very stale default this PR fixesBehaviour changes
dircache sizevalues: unchanged. Bounds unchanged: minimum 1024 (deliberately kept — the spectest CI legs rundircache size = 1024to exercise cache exhaustion and eviction), maximum 1048576, in-range values still round up to the next power of two.Size resolution
dircache sizedircache_resolve_size()resultTesting
utest_conf_dircache_resolve_sizeintest/afpd/subtests_conf.c: bounds matrix over the pure helper —-1 → 65536,512 → 65536(warn),1024 → 1024,100000 → 131072,2000000 → 1048576(clamp warn)meson test(Alpine container, CI build flags): 3/3 suites, 88 afpd subtests passeddircache size = 1024): both exit 0, zero failures