-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: dynamic dag traversal #163
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some comments after chatting with Alex in Helia WG
const dfsIter = dfsEntry.content({ | ||
signal, | ||
onProgress, | ||
offset, | ||
length | ||
}) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set blockReadConcurrency: 1 here.
set offset:0 and length to min bytes to retrieve to determine file type to ensure we only request whats needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated this to follow the same pattern as https://pkg.go.dev/net/http#DetectContentType for detecting the content type
for await (const chunk of exporterEntry.content({ | ||
signal, | ||
onProgress, | ||
offset, | ||
length | ||
})) { | ||
yield chunk | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test if we need to set blockReadConcurrency here, based on either offset===0 or isImageOrVideo
Title
feat: dynamic dag traversal
Description
This PR consolidates DAG traversal and streams when fetching dag-pb/unixfs. If the content type is an image or video, it attempts to return more quickly by doing a DFS traversal of the DAG and streaming the content as it is found. This is an enhancement to the existing DAG traversal and streaming mechanism.
A few callouts:
getStreamFromAsyncIterable
enhancedDagTraversal
enhancedDagTraversal
Fixes #52
Notes & open questions
It seems like we get a little performance boost with these changes. See ipfs/service-worker-gateway#529 also hyperfine benchmarking below. Note that the first hyperfine run was querying public endpoints (without instantiating helia), and the second was querying a local endpoint
The contents of
test-time-to-first-byte.js
is:Things still to do:
getStreamFromAsyncIterable
andgetStreamFromAsyncIterable
testsenhancedDagTraversal
Change checklist