feat: providers result limits for JSON and NDJSON#149
Open
lidel wants to merge 1 commit into
Open
Conversation
JSON delegated routing responses under-delivered: boxo's DefaultRecordsLimit of 20 acted as a pre-filter, and cacheFallbackIter silently dropped records without addresses. Production at delegated-ipfs.dev returned ~4 providers on JSON vs ~17 on NDJSON for the same CID. - raise the JSON cap to 100 and add a streaming cap of 1000, matching HTTP Routing v1 section 4.1.5; expose both as `--records-limit` and `--streaming-records-limit` with `SOMEGUY_*` env vars; reject negative input, 0 disables the cap - over-fetch from the underlying router by 3x (cap 3000) so that, after cacheFallbackIter drops addr-less records, the surfaced count is close to the caller's limit; cap the final stream via a new limitedIter wrapper
Comment on lines
+57
to
+61
| // cacheFallbackOverfetchMax caps the over-fetched limit so a large | ||
| // caller-side limit cannot blow up the DHT walk. Sized at 3x | ||
| // DefaultStreamingRecordsLimit so the multiplier applies on the | ||
| // streaming path too. The routing timeout bounds wall-clock. | ||
| cacheFallbackOverfetchMax = 3000 |
Contributor
There was a problem hiding this comment.
What is meant by blow up the DHT walk?
IIRC the limit passed to FindProviders() is just an upper-bound allowing the DHT client to terminate the DHT walk early if it has found enough providers. The DHT client will not do extra work if it didn't find enough providers, it will simply stop and return after it has queried the 20 closest peers.
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.
Someguy supports JSON (buffered) and NDJSON (streaming) response types.
Problem
JSON delegated routing responses under-delivered: iiuc boxo's
DefaultRecordsLimitof 20 acted as a pre-filter, and cacheFallbackIter silently dropped records without addresses.Anecdotally (cc @aschmahmann), production at
delegated-ipfs.devreturned ~4 providers on JSON (when opened in browser) vs ~17 on NDJSON for the same CID (/ipns/ipfs.tech).As a side problem, NDJSON stream had no cap, which is a bad default.
Fix (This PR)
--records-limitand--streaming-records-limitwithSOMEGUY_*env vars; reject negative input, 0 disables the cap