Repository navigation
fix: performance.read_ahead now reaches the prefetcher - #248
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
niland ran that manager's built-in defaults. A deploymentthat set
window_size: 128MBfor a streaming workload was prefetching 64 KB, and had no way tofind 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/configdescribed a strategy selector (strategy: simple|predictive|ml) over apattern 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 ininternal/fuseis a sequential-access detector with aprefetch window and five fields. Beyond
enabledthere was no field-name overlap at all, sothere 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_pathreaching no model loader is a claim about the software, and range-checking
learning_rateto0–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_sizegoes too. It iscompression_enabled's twin: a prominent 64MBdefault, 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 exactlyfuse.DefaultReadAheadConfig, which is what everymount 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(it is theworker 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 anempty
window_size(an empty floor is a floor of zero, not the default).window_sizethat is not a size at all,and a
ttlwritten without a unit.ttl: 5is five nanoseconds, silently, since yaml.v2reads a bare integer into a
time.Durationas a raw nanosecond count. Reporting a typo onlyonce the feature is switched on means it surfaces months later as a validation failure over a
line nobody touched.
other way: a mount should not be refused over settings nothing will read.
The
ttlomission was not found by hand.TestEveryDurationInTheSchemaIsValidatedwalks theconfig structs with reflection and fails for any
time.Durationthe checker does not cover; itfired the moment this change gave read-ahead a duration at all.
Presets and docs
Rewritten rather than relabeled.
readahead-simple.yamlbecamereadahead-disabled.yaml— itconfigured "no pattern detection, no prefetching", whose honest spelling is read-ahead off — and
readahead-ml.yamlis deleted, because a preset cannot be corrected into configuring amodel loader that does not exist.
docs/features/read-ahead.mdlost its ML training guide andits three-strategy comparison for the same reason, and gained the measured prefetch figures.
What this exposed and did not fix (#247)
min_sequentialhas no effect below 6, because the prefetch also requires confidence > 0.5 andconfidence is
sequentialHits / 10— two thresholds over one counter, of which only one isconfigurable. 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:
NewFileSystemtoNewReadAheadManager(filesystem, nil)makesTestNewFileSystemPassesTheConfiguredReadAheadfail on every field.MinSequential/ConcurrentReadsinbuildReadAheadConfigmakesTestBuildReadAheadConfigMapsEveryConfiguredValuefail naming both.performance.read_ahead.ttlentry fromvalidateDurationsmakes both thereflection walk and
TestValidateReportsAUnitlessReadAheadTTLEvenWhenDisabledfail.Gates:
go build,go vet, fullgo test -race ./..., coverage gate (30 packages at or abovefloor;
internal/config90.8% against an 88% floor),golangci-lint0 issues, markdownlint.