-
Notifications
You must be signed in to change notification settings - Fork 1.2k
slow key generation #1727
Comments
We want to go with For the sake of continuing with the rest of Benchmarks, you can use a pre-generated keypair by passing it Using the module directlyhttps://github.com/ipfs/js-ipfs#optionsinit CLI opts
|
As a datapoint for comparison, go-ipfs takes 0.17s
|
@daviddias @alanshaw do you want us to do that change (put it in our queue of things to do), or do you plan to make that change in the js-ipfs team? Note that the problem is not going to fix it for the browser. Is that ok?
Currently js-ipfs is at 10 seconds because of that generation. Creating the actual repo and adding a file takes ~100 ms (after the certificate is created) which is already pretty good. I hope we can get it into the same ballpark of the Go implementation. Startup speed of Go is superior to the one of Node.js, so it would be extremely hard to reach the same speed. |
@vasco-santos @jacobheun would you be able to ship libp2p/js-libp2p-crypto#130 soon or would you prefer to let @mcollina handle it? Either way, for the browsers, could you just add a JSON object with a bunch of keys before starting the profiling? Or alternatively, just load the key from a local http endpoint through a single get request, taking out all the keypair calls from the profiling graph and cutting the time spent on generating it. |
I'm more concerned about fixing the issue for browsers rather than the benchmarking itself. |
I would like to focus on the testbed and If @mcollina can handle it, it would be great. Otherwise, I can also shift priorities to tackle it. |
@mcollina go ahead and have fun trying the internals of libp2p :D |
Just wanted to shim in saying that We can do the same as |
Is there any update on this? We're building a chat app on OrbitDB, which creates a lot of files, and this is showing up as the big resource hog in our profiling too. We're using this in node, not the browser, so the |
@holmesworcester key generation only happens when you init a new node, not when adding files to ipfs etc. Can you open a new issue with the results of your profiling? |
js-ipfs is being deprecated in favor of Helia. You can #4336 and read the migration guide. Please feel to reopen with any comments by 2023-06-02. We will do a final pass on reopened issues afterwards (see #4336). This issue is most likely resolved in Helia, please try it out! |
As part of the benchmarking initiative, we have identified a first bottleneck in js-ipfs.
Adding a file to a local empty repo creates a new public/private key (see https://github.com/ipfs/benchmarks/blob/master/tests/local-add.js). This operation takes 3-6 seconds on our laptop, making the user experience on new repositories problematic. Also, it skews all the possible benchmarks, because it is hard to gain 3-6 seconds lost in this activity. During our call earlier this week, we talked about using a pre-generated certificate for benchmarking/improving the actual data transfer. However, this does not solve the problem for creating a new repository and new users.
We have conducted our analysis using node clinic. Here is a doctor visualization of that benchmark:
As it's evident, the event loop is blocking for a severe amount of time. We generated a flamegraph of the same activity:
As you can see, the vast majority of time is spent in the https://www.npmjs.com/package/keypair module. We can see two recommendations:
Note that approach 1 only works for Node.js, while 2 is essentially needed for browser environments.
The text was updated successfully, but these errors were encountered: