Skip to content
This repository has been archived by the owner on Aug 11, 2021. It is now read-only.

perf: lazy load format resolvers #145

Merged
merged 2 commits into from
Sep 11, 2018
Merged

perf: lazy load format resolvers #145

merged 2 commits into from
Sep 11, 2018

Conversation

alanshaw
Copy link
Member

The require time profile for starting an IPFS daemon (ipfs daemon) showed IPLD as a significant contributor to the total time spent requiring modules. This is because the formats are all required ahead of time:

screen shot 2018-08-24 at 10 18 47

In the trace above, you can see the IPLD dependency taking 386ms in total of require time. Of which, the default IPLD formats take around 200ms of time to require. You can see ipld-bitcoin, ipld-ethereum and ipld-zcash taking the majority of that time.

This PR adds support for these default modules lazily. You only suffer the require time when you use a particular format. So if you never use git, ethereum or zcash blocks (probably most people right now) they don't contribute to the startup time of your node.

screen shot 2018-08-24 at 10 18 15

Now IPLD takes 121ms to require.

The require time profile for starting an IPFS daemon (`ipfs daemon`) showed IPLD as a significant contributor to the total time spent requiring modules. This is because the formats are all required ahead of time.

In total, the default IPLD formats take around 200ms of time to require.

This PR adds support for these default modules lazily. You only suffer the require time when you use a particular format. So if you never use git, ethereum or zcash blocks (probably most people right now) they don't contribute to the startup time of your node.

License: MIT
Signed-off-by: Alan Shaw <alan@tableflip.io>
License: MIT
Signed-off-by: Alan Shaw <alan@tableflip.io>
@codecov
Copy link

codecov bot commented Aug 24, 2018

Codecov Report

Merging #145 into master will decrease coverage by 7.21%.
The diff coverage is 55.55%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #145      +/-   ##
==========================================
- Coverage   88.65%   81.44%   -7.22%     
==========================================
  Files           1        1              
  Lines         194      194              
==========================================
- Hits          172      158      -14     
- Misses         22       36      +14
Impacted Files Coverage Δ
src/index.js 81.44% <55.55%> (-7.22%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f493902...d613629. Read the comment docs.

@daviddias daviddias requested a review from vmx August 25, 2018 07:17
@daviddias daviddias added status/ready Ready to be worked P2 Medium: Good to have, but can wait until someone steps up labels Aug 25, 2018
Copy link
Member

@daviddias daviddias left a comment

Choose a reason for hiding this comment

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

Great catch!

@vmx vmx merged commit cb60257 into master Sep 11, 2018
@vmx vmx deleted the perf/lazy-load-resolvers branch September 11, 2018 09:42
alanshaw added a commit to ipfs/js-ipfs that referenced this pull request 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 lazy loading.

License: MIT
Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
alanshaw added a commit to ipfs/js-ipfs that referenced this pull request Nov 12, 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.

License: MIT
Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
P2 Medium: Good to have, but can wait until someone steps up status/ready Ready to be worked
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants