Skip to content

fix: performance.read_ahead now reaches the prefetcher - #248

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/176-wiring
Aug 3, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/176-wiring

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

Closes #176. Files #247 for what the wiring exposed and did not fix.

The defect

Every read-ahead setting was decoded, defaulted, range-checked at load, documented on its own
page and shipped in four preset config files — and read by nothing. The mount constructed its
read-ahead manager with a literal nil and ran that manager's built-in defaults. A deployment
that set window_size: 128MB for a streaming workload was prefetching 64 KB, and had no way to
find that out.

Third instance of the shape #156 and #244 had: accepted by every layer that reads
configuration, consulted by no layer that acts on it.

Why the block went from twenty keys to five

The reduction is the fix rather than a simplification of it. The two structs did not disagree
about a value; they disagreed about what read-ahead is.

internal/config described a strategy selector (strategy: simple|predictive|ml) over a
pattern detector with a confidence threshold and a prediction window, a bandwidth-capped
prefetcher, and an online-learning model — ml_model_path, learning_rate, pattern_depth,
model_update_interval. What exists in internal/fuse is a sequential-access detector with a
prefetch window and five fields. Beyond enabled there was no field-name overlap at all, so
there was nothing to pass through: the block was cut down to the detector's own knobs and wired.

Wiring the old block would have been worse than leaving it inert. A validated ml_model_path
reaching no model loader is a claim about the software, and range-checking learning_rate to
0–1 is what made the whole set look load-bearing — a user whose config is rejected for an
out-of-range value reasonably concludes the accepted values do something. Fifteen keys are
removed rather than deprecated, so a file still setting one fails to load with the key named.

performance.read_ahead_size goes too. It is compression_enabled's twin: a prominent 64MB
default, read by nothing, two lines above the block describing the same quantity with a
different default. Two names for one setting can only ever disagree.

Behavior at the default configuration is unchanged

config.NewDefault's block is now exactly fuse.DefaultReadAheadConfig, which is what every
mount has run all along, and tests on both sides of the seam assert the two stay equal.

Validation splits syntax from semantics

  • Checked only when enabled, because they are settings: concurrent_reads: 0 (it is the
    worker count, and zero starts no workers, so every prefetch is queued and never performed —
    read-ahead silently off while the config says on), min_sequential <= 0, ttl <= 0, and an
    empty window_size (an empty floor is a floor of zero, not the default).
  • Checked either way, because they are typos: a window_size that is not a size at all,
    and a ttl written without a unit. ttl: 5 is five nanoseconds, silently, since yaml.v2
    reads a bare integer into a time.Duration as a raw nanosecond count. Reporting a typo only
    once the feature is switched on means it surfaces months later as a validation failure over a
    line nobody touched.
  • Otherwise a disabled block is not validated. That is the original defect pointing the
    other way: a mount should not be refused over settings nothing will read.

The ttl omission was not found by hand. TestEveryDurationInTheSchemaIsValidated walks the
config structs with reflection and fails for any time.Duration the checker does not cover; it
fired the moment this change gave read-ahead a duration at all.

Presets and docs

Rewritten rather than relabeled. readahead-simple.yaml became readahead-disabled.yaml — it
configured "no pattern detection, no prefetching", whose honest spelling is read-ahead off — and
readahead-ml.yaml is deleted, because a preset cannot be corrected into configuring a
model loader that does not exist. docs/features/read-ahead.md lost its ML training guide and
its three-strategy comparison for the same reason, and gained the measured prefetch figures.

What this exposed and did not fix (#247)

min_sequential has no effect below 6, because the prefetch also requires confidence > 0.5 and
confidence is sequentialHits / 10 — two thresholds over one counter, of which only one is
configurable. The shipped default of 3 is inside that inert range, so the documented default
does not describe the default behavior. Reconciling them changes prefetch behavior at the
default configuration, which wants a measurement rather than a number nudged in passing while a
plumbing gap is closed. Filed as #247 and documented at the setting.

Verification

Both directions verified by mutation, not by prediction:

  • Reverting NewFileSystem to NewReadAheadManager(filesystem, nil) makes
    TestNewFileSystemPassesTheConfiguredReadAhead fail on every field.
  • Crossing MinSequential/ConcurrentReads in buildReadAheadConfig makes
    TestBuildReadAheadConfigMapsEveryConfiguredValue fail naming both.
  • Removing the performance.read_ahead.ttl entry from validateDurations makes both the
    reflection walk and TestValidateReportsAUnitlessReadAheadTTLEvenWhenDisabled fail.

Gates: go build, go vet, full go test -race ./..., coverage gate (30 packages at or above
floor; internal/config 90.8% against an 88% floor), golangci-lint 0 issues, markdownlint.

Every read-ahead setting was decoded, defaulted, range-checked at load,
documented on its own page and shipped in four presets — and read by
nothing, because the mount constructed its manager with a literal nil.
A deployment that set window_size: 128MB was prefetching 64KB and had
no way to find out.

The block goes from twenty keys to five, and the reduction is the fix
rather than a simplification of it. The two structs did not disagree
about a value; they disagreed about what read-ahead is. config
described a strategy selector over a pattern detector with a
confidence threshold, a bandwidth cap and an online-learning model
(ml_model_path, learning_rate, pattern_depth, model_update_interval);
fuse implements a sequential detector with five fields. Beyond
`enabled` there was no field-name overlap at all — nothing to pass
through — so the block was cut to the detector's own knobs.

Wiring the old block would have been worse than leaving it inert: a
validated ml_model_path reaching no model loader is a claim about the
software, and range-checking learning_rate to 0-1 is what made the
whole set look load-bearing. Fifteen keys are removed rather than
deprecated, so a file still setting one fails to load with the key
named. performance.read_ahead_size goes too — compression_enabled's
twin, a prominent 64MB default read by nothing, two lines above the
block describing the same quantity with a different default.

Behavior at the default configuration is deliberately unchanged:
config.NewDefault's block is now exactly fuse.DefaultReadAheadConfig,
which is what every mount has run all along, and tests on both sides
of the seam assert the two stay equal.

Validation splits syntax from semantics. concurrent_reads: 0 and an
empty window_size are rejected when enabled (zero workers means every
prefetch is queued and never performed: read-ahead silently off while
the config says on). A disabled block is otherwise not validated — a
mount should not be refused over settings nothing will read. But an
unparseable window_size and a unitless ttl are checked either way,
because those are typos rather than settings: `ttl: 5` is five
nanoseconds, silently, since yaml.v2 reads a bare integer into a
time.Duration as a raw nanosecond count. The ttl omission was found
by the reflection walk that pins every duration in the schema to
validateDurations, the moment this change gave read-ahead a duration.

readahead-simple.yaml becomes readahead-disabled.yaml (it configured
"no pattern detection, no prefetching", whose honest spelling is off)
and readahead-ml.yaml is deleted: a preset cannot be corrected into
configuring a model loader that does not exist.

One thing the wiring exposed and did not fix, filed as #247:
min_sequential has no effect below 6, because the prefetch also
requires confidence > 0.5 and confidence is sequentialHits/10 — two
thresholds over one counter, of which one is configurable. The shipped
default of 3 is inside that range, so the documented default does not
describe the default behavior. Reconciling them changes prefetch
behavior at the default configuration, which wants a measurement
rather than a number nudged in passing.

Closes #176
Refs #247
@scttfrdmn
scttfrdmn merged commit 4180ef9 into main Aug 3, 2026
23 checks passed
@scttfrdmn
scttfrdmn deleted the fix/176-wiring branch August 3, 2026 09:09
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.

performance.read_ahead is validated, documented, and read by nothing

1 participant