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

fix issue 6760, adding with hash-only, high CPU usage. #6764

Merged
merged 4 commits into from
Nov 18, 2019

Conversation

hcg1314
Copy link
Contributor

@hcg1314 hcg1314 commented Nov 15, 2019

IPFS daemon will create a IDENTITY for repo through function GenerateKeyPairWithReader. This action cost so much CPU resource. And IPFS daemon creates a fake repo for each ipfs add -n xxx.
So, i create a global fake node, all the calls ipfs add -n xxx can use this fake node to avoid GenerateKeyPairWithReader.

return nilNode,nil
}

func CloseFakeRepo() error {
Copy link
Member

Choose a reason for hiding this comment

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

I wouldn't bother with this. We don't actually need to close this node.

Copy link
Member

@Stebalien Stebalien left a comment

Choose a reason for hiding this comment

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

Thanks! Ideally we wouldn't even need a "nil node" but this looks like a good interim solution.

@@ -27,6 +28,43 @@ import (
)

type UnixfsAPI CoreAPI
var nilNode *core.IpfsNode
var lock sync.Mutex
Copy link
Member

Choose a reason for hiding this comment

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

Let's use a sync.Once.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

@Stebalien Stebalien merged commit 8c35862 into ipfs:master Nov 18, 2019
@Stebalien
Copy link
Member

Thanks!

@hcg1314 hcg1314 deleted the fix/6760 branch November 19, 2019 00:42
This was referenced Jan 17, 2020
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.

2 participants