refactor: delete dead code and guards against unreachable states - #4
Open
ctxswitch wants to merge 1 commit into
Open
refactor: delete dead code and guards against unreachable states#4ctxswitch wants to merge 1 commit into
ctxswitch wants to merge 1 commit into
Conversation
Removes the http-body-util dependency, the references stripe array (512 mutexes guarding two single atomic batch writes with no read-modify-write), four unreferenced SpaceLedger accessors, FromStr for Digest, ArtifactId::algorithm, ChannelService::gate, the publish_or_reject passthrough, the prefetch pool's active/peak atomics, empty_output's OnceLock, AwaitedRemoval, deleting_channels, the PredictedObject/PublishedBody/Fetched wrappers, and session_finished. The eviction column family's stored_len value was written at two sites, discarded by its only reader, and little-endian while its key is big-endian; it is now empty. Old stores stay readable because the reader already ignored it. Also drops guards against states that cannot occur: Ring::owner's checked_rem after the empty case returns, the u32 member index that saved no memory but cost a fallible conversion, ChannelId::new's nil-ULID retry loop, RecentUse::new's max(1) behind a validated config, ensure_default's id check, prefix_end's carry loop over a base32 prefix whose last byte is never 0xFF, decode_eviction_key's repeated starts_with and two unreachable map_err arms, and serve_artifact's unsatisfiable pre-check along with the unreachable! and the Eq/PartialEq derives that existed only to serve it.
3 tasks
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.
Summary
Third of six stacked PRs. Based on
cleanup/phase-2-perf(#3) — review the stackin order. Net −179 lines, no new behaviour.
Dead or vestigial, each confirmed unreferenced before removal: the
http-body-utildependency (declared, used nowhere; still present transitively via axum/reqwest), the
referencesstripe array, fourSpaceLedgeraccessors,impl FromStr for Digest,ArtifactId::algorithm(),ChannelService::gate(), thepublish_or_rejectpassthrough, the prefetch pool's
active/peakatomics,empty_output()'sOnceLock,AwaitedRemoval,deleting_channels, thePredictedObject/PublishedBody/Fetchedwrappers, andsession_finished.Mode's re-exporttightened to
pub(crate).The
referencesstripes were 512 mutexes guarding two single atomic RocksDB batchwrites with no read-modify-write; the publish path writes reference rows under the
artifact stripe anyway, so the one race they could have serialized wasn't theirs to
serialize. The
artifactsstripes are load-bearing and stay.The eviction column family's
stored_lenvalue was written at two sites, discardedby its only reader, and little-endian while its key is big-endian. It is now empty.
Also removes guards against states that cannot occur:
Ring::owner'schecked_remafter the empty case has already returned, the
u32member index (a fallibleconversion that saved no memory —
(u64,u32)and(u64,usize)are both 16 bytes),ChannelId::new's nil-ULID retry loop,RecentUse::new's.max(1)behind a configvalidatethat already rejects zero,ensure_default's id check,prefix_end'scarry loop over a base32 prefix whose last byte is never
0xFF,decode_eviction_key's repeatedstarts_withand two unreachablemap_errarms,and
serve_artifact's unsatisfiable pre-check together with theunreachable!()itforced and the
Eq, PartialEqderives that existed only to serve it.Verification
make ciclean, includingclippy --all-targets -- -D warnings.tests/integration/maintenance.rs(8 tests) passes, covering the eviction valuechange.
tests/integration/channels.rsexplicitly skips the eviction value in itson-disk-format assertions, so no format guard moves.
tests/integration/domain.rsstill asserts 1024 freshChannelIds are non-nilafter the retry loop came out, and now asserts
id.to_string() == "sha256:<hex>"in place of the deleted
algorithm()accessor —Displaycarries the algorithm,so the assertion still fails if it breaks.
src/cache/space_test.rsreads throughsnapshot()instead of the four deletedaccessors — the same lock, and the path telemetry actually uses.
empty_output's newconstis covered byzero_size_actions_are_elided_and_answered_locally, which fails if the literal iswrong.
make ciDocumentation and examples are accurate
New or changed behavior has test coverage
Operational impact
No store-format bump. Eviction rows now carry an empty value, and the only reader
already discarded it, so existing stores stay readable in both directions.
One rare-path narrowing: removing
AwaitedRemovalmeans that if a caller's future isdropped mid-
remove_fileinsidediscard(), the temporary file is no longer retriedasynchronously. Accounting still settles conservatively via
PendingSettlement::drop,the file is cleaned by
remove_temporary_files()on the next startup reconcile, andthe over-commit reconciles on the next
SpaceLedger::refresh— which is the samefallback the guard itself relied on.
Prefetch debug logs lose the
published_meanwhileandpeak_concurrencyfields.Debug telemetry only; no metric or operator-facing contract changes.
Review notes
One plan item was wrong and is reported rather than worked around.
Digest::parsewas described as duplicating validation that
hex::decode_to_slicealready performs.It mostly does — length and hex-ness — but
decode_to_sliceaccepts uppercase.tests/integration/domain.rsasserts uppercase is rejected andDisplayemitslowercase, so the lowercase requirement is load-bearing canonicalisation: deleting
the whole pre-check would have made
sha256/ABC…a second URL form for the sameartifact. The length and
is_ascii_hexdigitchecks are gone; a one-line uppercaserejection stays, with a comment saying why.
One item was deliberately skipped.
rewrite_metadata'sTransform::Nonearm isgenuinely dead —
fetch_urlroutesNoneinto the streaming branch andcached_outcomereturns before the call — but thematchmust stay exhaustive overTransform. The only exits are replacing it withunreachable!(), which is the sameclass of dead code this PR is removing, or splitting
TransformintoNoneplus athree-variant
MetadataTransform— an added type touching the constructors,upstream_accept,cache_variant, and both dispatch sites. That is a type-levelrefactor rather than a deletion, so it belongs with the error-type merge in the next
PR if it is wanted at all.
Review is probably best spent on
src/storage/local/artifact_files.rs(theAwaitedRemovalpath above) andsrc/storage/metadata/rocksdb.rs(eviction value,prefix_end,decode_eviction_key). The rest is unreferenced-symbol removal thatthe compiler validates.