Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

perf: lazy load IPLD formats #1704

Merged
merged 2 commits into from
Nov 12, 2018
Merged

perf: lazy load IPLD formats #1704

merged 2 commits into from
Nov 12, 2018

Conversation

alanshaw
Copy link
Member

@alanshaw alanshaw commented Nov 9, 2018

This PR uses the new loadFormat option for IPLD to lazily require IPLD formats in order to reduce the startup time for the node.

If you're feeling like you've seen this before then, for reference:

The PR ipld/js-ipld#164 undid the work done in ipld/js-ipld#145 and ipld/js-ipld#178 re-enabled the ability to do so. This PR makes use of this new ability to lazy load the formats.

This PR uses the new `loadFormat` option for IPLD to lazily require IPLD formats in order to reduce the startup time for the node.

If you're feeling like you've seen this before then, for reference:

The PR ipld/js-ipld#164 undid the work done in ipld/js-ipld#145 and ipld/js-ipld#178 re-enabled lazy loading.

License: MIT
Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
@ghost ghost assigned alanshaw Nov 9, 2018
@ghost ghost added the status/in-progress In progress label Nov 9, 2018
License: MIT
Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
@alanshaw
Copy link
Member Author

alanshaw commented Nov 12, 2018

Merging as the failures are because of an unrelated libp2p issue

@alanshaw alanshaw merged commit aefb261 into master Nov 12, 2018
@alanshaw alanshaw deleted the perf/lazy-load-ipld-formats branch November 12, 2018 16:29
@ghost ghost removed the status/in-progress In progress label Nov 12, 2018
@mikeal
Copy link
Contributor

mikeal commented Nov 12, 2018

Love this, +1, but we should maybe start another thread about trying to make this work with code splitting in webpack as well. Getting these out of bundles would be a big win :)

@daviddias
Copy link
Member

Can we go even one more lever deeper in the lazyness and make the formats loaded through IPFS if the node gets a CID for which it doesn't have the IPLD Format code yet?

@mikeal
Copy link
Contributor

mikeal commented Nov 12, 2018

@diasdavid that should be how this works :) All the imports are in getters, so they won't be called until we get a request for a codec, which should only happen if we're working with a block that is using that codec.

@daviddias
Copy link
Member

daviddias commented Nov 13, 2018

I mean, not even bundle it. Fetch the code from IPFS while the node is already running :D

@alanshaw
Copy link
Member Author

Can we go even one more lever deeper in the lazyness and make the formats loaded through IPFS if the node gets a CID for which it doesn't have the IPLD Format code yet?

❤️ YES 🤯

IPFS module loader? https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#Dynamic_Imports

//cc @achingbrain

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants