Skip to content
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

perf: Use the libipld built in way to scrape references #388

Merged
merged 2 commits into from
Oct 21, 2022

Conversation

rklaehn
Copy link
Contributor

@rklaehn rklaehn commented Oct 21, 2022

...without having to create an AST. Should be much faster.

This has been working all the time for dag-cbor since we needed that at actyx, but I have also made the dag-pb case a bit faster in ipld/libipld#155

@@ -1400,18 +1400,16 @@ impl<T: ContentLoader> Resolver<T> {
/// Extract links from the given content.
pub fn parse_links(cid: &Cid, bytes: &[u8]) -> Result<Vec<Cid>> {
let codec = Codec::try_from(cid.codec()).context("unknown codec")?;
let mut cids = BTreeSet::new();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might argue that a hashset would be faster here, and you would not be wrong. I guess it is my determinism fetish...

@rklaehn rklaehn requested a review from Arqu October 21, 2022 10:04
dignifiedquire
dignifiedquire previously approved these changes Oct 21, 2022
Copy link
Contributor

@dignifiedquire dignifiedquire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice 💙

@rklaehn
Copy link
Contributor Author

rklaehn commented Oct 21, 2022

Note that with this I am not entirely convinced that sending the cids over the RPC is worth it. The store can scrape the links. Unless we foresee a scenario where you would want to send different links than the block contains, but that would be weird...

@rklaehn rklaehn force-pushed the rklaehn/faster-link-scraping branch from f84da6e to d57b12a Compare October 21, 2022 13:01
@rklaehn
Copy link
Contributor Author

rklaehn commented Oct 21, 2022

Oh well, another error. Made an issue for this since it is unrelated to this: n0-computer/beetle#124

@dignifiedquire dignifiedquire merged commit 121b968 into n0-computer:main Oct 21, 2022
@rklaehn rklaehn deleted the rklaehn/faster-link-scraping branch October 21, 2022 16:23
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.

3 participants