Repository navigation
fix(eviction): correct inverted S3-FIFO config validation in update - #17
Closed
detail-app[bot] wants to merge 1 commit into
Closed
detail-app[bot] wants to merge 1 commit into
detail-app[bot] wants to merge 1 commit into
Conversation
Author
|
Closing this pull request because it has had no human activity in 30 days (since 2026-09-11) and was opened 30 days ago. Detail closes its pull requests once they are more than 30 days old and have had no human activity for 14 days. If this change is still useful, reopen the pull request and Detail won't close it again. To keep a Detail pull request open, add the |
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.
Detail bug report: View on Detail
Bug
S3Fifo::update(foyer-memory/src/eviction/s3fifo.rs) validatedsmall_queue_capacity_ratiowith an inverted guard: it returnedErrfor in-range values (rejecting even the documented default0.1) and silently accepted/stored out-of-range values (<= 0or>= 1).S3Fifo::new's assertion and of the siblingLru/Lfuupdatevalidations, which all reject out-of-range ratios.Errreturned before the capacity recompute, a valid config update also aborted the always-performed capacity resize, leaving the cache at its old capacity.2.0setsmall_weight_capacity = 2 * capacity), which defeats S3-FIFO's small/main/ghost partition trigger (small_weight > small_weight_capacity) and collapses eviction into a degenerate mode.RawCache::resize) passesconfig: None, so the brokenSome(config)branch is never exercised in production or tests — but it's the branch theOption<&Config>signature explicitly intends to support.Fix
Negated the guard so the error fires when the ratio is out of range, matching
lfu.rs/lru.rs:Also appended
"new configuration ignored"to the error message for parity with the sibling implementations. No other behavior changed; thenew,push/pop/evict,acquire,release,remove, andclearpaths are untouched.Testing
Added two focused unit tests in the
s3fifotestsmodule (there was previously no coverage ofS3Fifo::update):test_s3fifo_update_with_valid_config— asserts valid ratios (incl. the default0.1and near-boundary0.01/0.999) returnOk, the new config is stored, andsmall_weight_capacity/ghost_queue.capacityare recomputed (i.e. the capacity resize is not aborted).test_s3fifo_update_with_invalid_config— asserts out-of-range values (0.0,1.0,-0.5,2.0,±∞) returnErrwithErrorKind::Config, the message recites the valid range, and the existing config and derived capacities are left untouched on rejection.Both tests use the existing in-module test patterns (
TestS3Fifo, direct field access like the existingtest_s3fifo). A proposed capacity-only-resize (config: None) test was excluded as redundant with the existingraw::tests::test_s3fifo_cache_resize, which exercises that production path end-to-end.Verification run (with
--features strict_assertions, matching CI):foyer-memorysuite: 33/33 pass (incl.raw::tests::test_s3fifo_cache_resizeand all eviction*_cache_fuzzytests).foyerumbrella crate:cargo check -p foyerandcargo nextest run -p foyer(12/12) pass.cargo check/cargo build).cargo fmt -p foyer-memory -- --checkand whole-workspace nightly fastidiouscargo +nightly fmt --all -- --config-path rustfmt.nightly.toml --checkclean.cargo clippy -p foyer-memory --all-targets --features strict_assertions -- -D warningsexits 0. The only emitted warning is a pre-existing environment artifact (unknown_lintsfor the workspace-allowedclippy::chunks_exact_to_as_chunks, unrecognized by the local rustc-1.91 toolchain) — confirmed identical on an unmodifiedgit stashbaseline and not attributable to this change.cargo-machete(no unused deps),typos,taplo fmt --check, Grafana JSON minification check, and the CI license gate (hawkeye check) all pass.Two procedures could not be run verbatim and are noted for transparency:
cargo x --fast(the README's local gate) runs a mutatingcheck()step (cargo sort -w,taplo fmt,jsonrewrites) plus 8 example binaries; I ran the read-only--checkequivalents and the non-mutating xtask sub-steps instead to avoid spurious diffs. The one component that failed,cargo sort --check, fails identically on an unmodified baseline (tool-version drift on untouchedCargo.tomlfiles) and is not a CI gate.licensesubcommand invokes the legacylicense-eye, which cannot parse the repo's.licenserc.tomlin this environment; CI useshawkeye checkinstead, which passes.Automatic Fixes PRs can be configured here.