You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Remove unused PtrHash remapping and vendored epserde - #175
DiskGraph always uses index_no_remap(), but ingestion still builds and serializes an unused remapping table. Remove that parameter, table, scratch storage, packed-storage module, and dense index() API, eliminating cacheline-ef.
Replace the patched, vendored epserde 0.8 copy with upstream epserde 0.13.2. Remove the Cargo patch, copied source, standalone CI step, and vendor provenance. Preserve the other dependency security fixes from #172 and keep maligned absent. Regenerate notices for all four shipped artifact graphs.
Breaking change: epserde now writes format 2.0 with SHA-256 type/alignment hashes. Rebuild existing indexes from source data; do not resume ingestion from an old primary-key-map checkpoint. Frozen 0.8 fixtures remain as rejection tests.
Hash files now use epserde's exact-length, file-backed mmap() API in both query and ingestion loaders. The padded load_mmap() helper could accept truncated current-format files and silently change lookup slots. Regression tests reproduce that failure before the switch and verify rejection afterward; upstream epserde remains unmodified.
cargo test --locked -p diskgraph-ptrhash: 12 passed, 7 ignored.
cargo test --locked -p diskgraph-index --test epserde_compat: 8 passed; both hashers and all key shapes reject the frozen 0.8 files, round-trip current indexes, and reject truncation by 1 through 32 bytes. These eight cases all failed against the padded loader, accepting a missing final byte.
cargo test --locked -p diskgraph-index --lib: 27 passed, including a real shard-loader test for 10,000 correct row-ID lookups and rejection of truncated copies.
The shard-loader regression also passes with --features pkhash128.
Requested requirement: remove unused remapping and eliminate cacheline-ef/maligned. Previously ingestion constructed a table that production lookups bypassed, and main retained a patched epserde 0.8 copy. The sufficient change removes that path and upgrades the remaining serializer dependencies; it deliberately requires rebuilding existing indexes. No legacy reader or migration is included.
Verification: construction/lookup, serialized and mmap round trips, old-format rejection, both production crates compiling, dependency-tree inspection, and regenerated artifact checks. Stop when the unused path and advisory dependency are absent with these checks passing. After rebasing on main including #172, all 8 compatibility tests and 27 index unit tests pass. The compatibility cases reproduce truncation acceptance with the padded loader and now reject 1 through 32 missing bytes; the real shard-loader regression passes in both hash modes. Frozen 0.8 files are retained as rejection fixtures; current indexes round-trip through all three loaders.
Upgrade epserde; remove cacheline-ef, direct mem_dbg, and redundant derive dependency.
Replace the local epserde backport with upstream 0.13.2 and keep maligned absent.
packages/diskgraph/Cargo.lock
Resolved dependencies
Regenerate for the reduced dependency graph.
Pin the upgraded serializer and omit removed crates.
packages/diskgraph/deny.toml
Advisory policy
Replace the obsolete backport explanation with upstream epserde 0.13.
Keep the existing advisory-free policy accurate.
packages/diskgraph/diskgraph-ptrhash/src/lib.rs
PtrHash, PtrHashParams, construction and lookup
Remove remapping parameter, state, generic, construction pass, and dense index API; retain direct pilot access; mark phantom parameters and keep the bucket function fully copied for epserde 0.13.
Mapped hash loading, lookup, and truncation regression
Use epserde 0.13 MemCase ownership and uncase; use exact-length file-backed mmap instead of padded load_mmap; test correct row IDs and truncation rejection in both hash modes.
Preserve mapped lookups and reject truncated files before they can change row IDs; keep the routing-hasher import available in both tested modes.
packages/diskgraph/diskgraph-ingest/src/lib.rs
write_pk_hash_and_data
Adapt serialization to the unsafe API with its validity invariant.
Write typed remap-free hashes with epserde 0.13.2.
packages/diskgraph/diskgraph-ptrhash/src/test.rs
Construction and persistence regressions
Use slot bounds; test serialized/mapped lookups for each key type and reject the previous file-format version.
Verify collision-free lookup and deliberate format incompatibility.
Assert old-version rejection, verify new-index round trips, and reject each truncation from 1 through 32 bytes using the production mapping API for both hashers and all key types.
Replace the old compatibility promise with verified rebuild behavior.
The workspace upgrades Epserde from 0.8 to 0.13.2 and removes the local Epserde copy. PtrHash removes remapping and packed-storage support, returning raw slots bounded by max_index(). Index and ingest code use typed mmap loading and updated lookup calls. Tests cover current-format round trips, rejection of old-format indexes, and truncated files. Artifact inventories are refreshed for the updated dependencies.
The change map misses a proven safety regression in the remap-free lookup design. The PR changes index_no_remap from the base revision's bounds-checked pilot access to get_unchecked at `packages/d…
Replace the unchecked pilot read with self.pilots.as_ref()[b], or make the lookup unsafe/private and enforce the pilot-length invariant before access. Add regression tests for DefaultPtrHash::default() and for a deserialized or mapped v…
Pr Size
The pull request changes 77 files. This exceeds the limit of 40 files.
Split the pull request into smaller, reviewable units.
Passed checks: 1 passed
Check name
Status
Explanation
Public Resource Access
PASS. The changed external references are public. The PR changes the epserde source from a local path to the crates.io registry and updates registry package records; anonymous requests returned 200 fo…
Full details: Public Resource Access
Explanation
PASS. The changed external references are public. The PR changes the epserde source from a local path to the crates.io registry and updates registry package records; anonymous requests returned 200 for the registry and all 10 new/changed crate records, including epserde 0.13.2. Updated repository origins for epserde, aliasable, allocator-api2, hashbrown, maybe-dangling, mem_dbg, and nix also returned 200. Added notice links were reachable or redirected successfully.
Full details: Change Map Design Review
Explanation
The change map misses a proven safety regression in the remap-free lookup design. The PR changes index_no_remap from the base revision's bounds-checked pilot access to get_unchecked at packages/diskgraph/diskgraph-ptrhash/src/lib.rs:485-490. The public Default implementation still creates zero reducers and an empty pilots vector at lines 216-240. FastReduce::reduce returns 0 for a zero divisor, so DefaultPtrHash::default().index_no_remap(key) reads pilot 0 out of bounds through safe API. The changed tests cover constructed valid hashes and valid serialization round trips, but not the default value or malformed short pilot storage. The proposed design therefore does not preserve safe behavior, and its safety comment only establishes an invariant for successful construction.
Resolution
Replace the unchecked pilot read with self.pilots.as_ref()[b], or make the lookup unsafe/private and enforce the pilot-length invariant before access. Add regression tests for DefaultPtrHash::default() and for a deserialized or mapped value with fewer pilots than buckets_total; verify that invalid values fail safely. Update the marked Change map to identify this safe-API invariant, the prior bounds-checked behavior, the smallest sufficient fix, and the focused verification.
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Warning
Review coverage is incomplete: 2 files could not be fully reviewed. Findings from completed review steps are included; see review info for details.
Use an isolated temporary directory for the mmap round-trip artifact.
The fixed filenames are shared by concurrent test processes. A concurrent write can make another invocation load incomplete or invalid serialized data and panic at load_mmap(...).unwrap(). The test also leaves the artifacts behind.
333-337: Minor · Stability & Availability · Quick win
Write test artifacts to a per-run temporary directory.
The test maps the file and then uses the mapped view. Two concurrent test processes can rewrite the same deterministic file because the path and file name are fixed. This can make the test fail while the mapping is in use. Add tempfile under [dev-dependencies], and keep the TempDir alive until mapped is dropped.
Suggested fix
- let output_dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))- .join("../target/test-artifacts/remap-free");- std::fs::create_dir_all(&output_dir).unwrap();- let path = output_dir.join(concat!($name, ".bin"));+ let output_dir = tempfile::tempdir().unwrap();+ let path = output_dir.path().join(concat!($name, ".bin"));
std::fs::write(&path, buffer.as_bytes()).unwrap();
Files not fully reviewed because their changes were unavailable: 2
THIRD-PARTY.txt
3rdparty/notices/inventory.json
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 9 remain after this review.
haoweiyu-kumo
changed the title
Remove unused PtrHash remapping and maligned dependency
Remove unused PtrHash remapping and vendored epserde
Nov 4, 2026
45-48: Minor · Stability & Availability · Quick win
Use an isolated temporary directory for each compatibility test.
Two concurrent processes running the same generated test can write the same fixed file while another process is loading or using its load_mmap view. A completed load_mem view is independent after its read finishes, but it can still race while loading. Keep the temporary directory alive until all views are dropped.
Suggested fix
- let output_dir = Path::new(env!("CARGO_MANIFEST_DIR"))- .join("../target/test-artifacts/epserde-compat");- std::fs::create_dir_all(&output_dir)?;- let output = output_dir.join(concat!(stringify!($name), ".bin"));+ let temp_dir = tempfile::tempdir()?;+ let output = temp_dir.path().join(concat!(stringify!($name), ".bin"));
Files not fully reviewed because their changes were unavailable: 2
THIRD-PARTY.txt
3rdparty/notices/inventory.json
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.
Focused ARM64 validation passed: ptrhash tests with and without default features; current-format serialization/mmap round trips; GxHash128 checks across four key shapes and rejection of a different hasher type; generated artifact manifests for all four shipped graphs; notice inventory and 18 focused notice/license tests. The intentional old-index format rejection is documented by this PR.
One P1 finding remains: a truncated current-format hash file can be accepted and produce incorrect lookups. The reproduction and affected loader are recorded inline. This approval leaves that finding outstanding.
The full Rust workspace, GPU tests, and native Windows builds were not run in this review.
498-500: Minor · Stability & Availability · Quick win
Use a per-run temporary directory for the truncation test files.
The test writes fixed file names under packages/diskgraph/target/test-artifacts/pkmap-truncation. The path ignores CARGO_TARGET_DIR, and the files remain after the run. Two concurrent runs of this test in one checkout write the same files. std::fs::write truncates existing files, so one run can truncate a file that the other run has memory-mapped. Accessing pages past the new end of the file can fault and fail or crash the test.
tempfile is already declared for this crate. A per-run directory removes the shared paths and the leftover files. dir is declared before shard, so the shard is dropped before the directory is removed.
♻️ Proposed change
- let output = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))- .join("../target/test-artifacts/pkmap-truncation");- std::fs::create_dir_all(&output)?;+ let dir = tempfile::tempdir()?;+ let output = dir.path();
Files not fully reviewed because their changes were unavailable: 2
THIRD-PARTY.txt
3rdparty/notices/inventory.json
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.
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
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
DiskGraph always uses
index_no_remap(), but ingestion still builds and serializes an unused remapping table. Remove that parameter, table, scratch storage, packed-storage module, and denseindex()API, eliminatingcacheline-ef.Replace the patched, vendored epserde 0.8 copy with upstream epserde 0.13.2. Remove the Cargo patch, copied source, standalone CI step, and vendor provenance. Preserve the other dependency security fixes from #172 and keep
malignedabsent. Regenerate notices for all four shipped artifact graphs.Breaking change: epserde now writes format 2.0 with SHA-256 type/alignment hashes. Rebuild existing indexes from source data; do not resume ingestion from an old primary-key-map checkpoint. Frozen 0.8 fixtures remain as rejection tests.
Hash files now use epserde's exact-length, file-backed
mmap()API in both query and ingestion loaders. The paddedload_mmap()helper could accept truncated current-format files and silently change lookup slots. Regression tests reproduce that failure before the switch and verify rejection afterward; upstream epserde remains unmodified.Change map
File-by-file rationale
Testing Done
Rust commands run from
packages/diskgraph/after rebasing on currentmain, including #172:cargo check -q -p diskgraph-ingest -p diskgraph-indexpassed.cargo test --locked -p diskgraph-ptrhash: 12 passed, 7 ignored.cargo test --locked -p diskgraph-index --test epserde_compat: 8 passed; both hashers and all key shapes reject the frozen 0.8 files, round-trip current indexes, and reject truncation by 1 through 32 bytes. These eight cases all failed against the padded loader, accepting a missing final byte.cargo test --locked -p diskgraph-index --lib: 27 passed, including a real shard-loader test for 10,000 correct row-ID lookups and rejection of truncated copies.--features pkhash128.cargo test --locked --offline -p diskgraph-ptrhash --no-default-features: 9 passed, 7 ignored.rustfmt --check, artifact-manifest/notice checks, repository documentation validation, andgit diff --checkpassed.cargo tree --locked --offline --all-featuresand all four artifact graphs contain registry epserde 0.13.2, with neithercacheline-efnormaligned.python -m unittest test.scripts.test_gen_third_party: 10 passed.Checklist