Skip to content

feat(dag/walker): BloomTracker experiment#1124

Draft
lidel wants to merge 15 commits intomainfrom
feat/provide-entity-roots-with-dedup
Draft

feat(dag/walker): BloomTracker experiment#1124
lidel wants to merge 15 commits intomainfrom
feat/provide-entity-roots-with-dedup

Conversation

@lidel
Copy link
Member

@lidel lidel commented Mar 20, 2026

Warning

not ready for review, this is a sandbox for running CI

@lidel lidel force-pushed the feat/provide-entity-roots-with-dedup branch from c16a5b7 to 4dad6c1 Compare March 20, 2026 21:57
VisitedTracker interface for memory-efficient DAG traversal dedup.
BloomTracker uses a scalable bloom filter chain (~4 bytes/CID vs ~75
for a map), enabling dedup on repos with tens of millions of CIDs.

- BloomTracker: auto-scaling chain, configurable FP rate via BloomParams,
  unique random SipHash keys per instance (uncorrelated FPs across nodes)
- MapTracker: exact dedup for tests and small datasets
- *cid.Set satisfies the interface for drop-in compatibility
- go.mod: update ipfs/bbloom to master (for NewWithKeys)
@lidel lidel force-pushed the feat/provide-entity-roots-with-dedup branch from 4dad6c1 to c8962fc Compare March 21, 2026 03:15
iterative DFS walker that integrates VisitedTracker dedup directly
into the traversal loop, skipping entire subtrees in O(1).

- LinksFetcherFromBlockstore: extracts links from any codec registered
  in the global multicodec registry (dag-pb, dag-cbor, raw, etc.)
- ~2x faster than legacy go-ipld-prime selector traversal (no selector
  machinery, simpler decoding, fewer allocations)
- WithLocality option for MFS providers to skip non-local blocks
- best-effort error handling: fetch failures log and skip, do not mark
  the CID as visited (allows retry via another pin or next cycle)
- benchmarks comparing BlockAll vs WalkDAG across dag-pb, dag-cbor,
  and mixed-codec DAGs
@lidel lidel force-pushed the feat/provide-entity-roots-with-dedup branch from 19bf557 to 224c2ae Compare March 21, 2026 03:46
@codecov
Copy link

codecov bot commented Mar 21, 2026

Codecov Report

❌ Patch coverage is 78.89610% with 65 lines in your changes missing coverage. Please review.
✅ Project coverage is 62.75%. Comparing base (abc1a94) to head (56a0a31).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
pinning/pinner/dspinner/uniquepinprovider.go 57.14% 16 Missing and 8 partials ⚠️
dag/walker/walker.go 80.95% 10 Missing and 6 partials ⚠️
dag/walker/entity.go 77.94% 11 Missing and 4 partials ⚠️
dag/walker/visited.go 89.33% 4 Missing and 4 partials ⚠️
provider/provider.go 92.00% 2 Missing ⚠️

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1124      +/-   ##
==========================================
+ Coverage   62.55%   62.75%   +0.19%     
==========================================
  Files         261      265       +4     
  Lines       26208    26522     +314     
==========================================
+ Hits        16395    16644     +249     
- Misses       8125     8169      +44     
- Partials     1688     1709      +21     
Files with missing lines Coverage Δ
provider/provider.go 90.16% <92.00%> (+19.11%) ⬆️
dag/walker/visited.go 89.33% <89.33%> (ø)
dag/walker/entity.go 77.94% <77.94%> (ø)
dag/walker/walker.go 80.95% <80.95%> (ø)
pinning/pinner/dspinner/uniquepinprovider.go 57.14% <57.14%> (ø)

... and 9 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

lidel added 13 commits March 21, 2026 05:23
emits entity roots (files, directories, HAMT shards) skipping
internal file chunks. core of the +entities provide strategy.

- NodeFetcherFromBlockstore: detects UnixFS entity type from the
  ipld-prime decoded node's Data field
- directories and HAMT shards: emit and recurse into children
- non-UnixFS codecs (dag-cbor, dag-json): emit and follow links
- same options as WalkDAG: WithVisitedTracker, WithLocality
- tests: dag-pb, raw, dag-cbor, mixed codecs, HAMT, dedup,
  error handling, stop conditions
catch unexpected regressions in ipfs/bbloom behavior or BloomParams
derivation that would silently degrade the false positive rate.

- measurable rate (1/1000): 100K probes produce observable FPs,
  asserts rate is within 5x of target
- default rate (1/4.75M): 100K probes must produce exactly 0 FPs
- NewPrioritizedProvider: stream init error no longer stops remaining
  streams (e.g. MFS flush error does not prevent pinned content from
  being provided)
- NewConcatProvider: concatenates pre-deduplicated streams without
  its own visited set, for use with shared VisitedTracker
…vider

NewUniquePinnedProvider: emits all pinned blocks with cross-pin
dedup via shared VisitedTracker (bloom or map). walks recursive pin
DAGs first, then direct pins.

NewPinnedEntityRootsProvider: same structure but uses WalkEntityRoots,
emitting only entity roots and skipping internal file chunks.

existing NewPinnedProvider is unchanged.
- remove unused daggen variable in uniquepinprovider_test.go
…tency

match the defensive read-side ctx.Done select pattern already used by
NewPrioritizedProvider in the same file
- deduplicate LinkSystem construction used by both
  LinksFetcherFromBlockstore and NodeFetcherFromBlockstore
- wrap blockstore with NewIdStore so identity CIDs (multihash 0x00,
  data inline in the CID) are decoded without a datastore lookup
identity CIDs (multihash 0x00) embed data inline, so providing them
to the DHT is wasteful. the walker now traverses through identity
CIDs (following their links) but never emits them.

- add isIdentityCID check to WalkDAG and WalkEntityRoots
- simplify WalkEntityRoots emit/descend logic
- tests for identity raw leaf, identity dag-pb directory with normal
  children, normal directory with identity child
- inline identity CID check (c.Prefix().MhType == mh.IDENTITY) in all
  emit paths: WalkDAG, WalkEntityRoots, and direct pin loops in both
  NewUniquePinnedProvider and NewPinnedEntityRootsProvider
- move all identity CID tests to dag/walker/identity_test.go
- add provider-level identity tests for direct pins and recursive DAGs
the stack-based DFS was pushing children in link order, causing
the last child to be popped first (right-to-left). reverse children
before pushing so the first link is on top and gets visited first.

this matches the legacy fetcherhelpers.BlockAll selector traversal
(ipld-prime iterates list/map entries in insertion order) and the
conventional DFS order described in IPIP-0412.

- walker.go, entity.go: slices.Reverse(children) before stack push
- walker.go: document traversal order in WalkDAG godoc
- entity.go: document order parity in WalkEntityRoots godoc
- walker_test.go, entity_test.go: add sibling order regression tests
a corrupted pin entry was stopping the entire provide cycle because
the goroutine returned on RecursiveKeys/DirectKeys error. change to
continue so remaining pins are still provided (best-effort).

the error from the pinner iterator already contains context (bad CID
bytes, datastore key, etc.) -- sc.Pin.Key is zero-value on error so
including it in the log would be noise.

matches the best-effort pattern used in WalkDAG/WalkEntityRoots
where fetch errors are logged and skipped.
- collectLinks: note that map keys are not recursed (no known codec
  uses link-typed map keys)
- detectEntityType: extract c.Prefix() once for readability
- grow: document MinBloomCapacity invariant that prevents small-bitset
  FP rate issues in grown blooms
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.

1 participant