-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Conversation
core/coreapi/unixfs.go
Outdated
return nilNode,nil | ||
} | ||
|
||
func CloseFakeRepo() error { |
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
core/coreapi/unixfs.go
Outdated
@@ -27,6 +28,43 @@ import ( | |||
) | |||
|
|||
type UnixfsAPI CoreAPI | |||
var nilNode *core.IpfsNode | |||
var lock sync.Mutex |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
use sync.Once instead
Thanks! |
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.