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

Remove expensive bls key serialization code and use the cached version #3217

Merged
merged 1 commit into from
Jul 15, 2020

Conversation

rlan35
Copy link
Contributor

@rlan35 rlan35 commented Jul 14, 2020

Remove the usage of ToLibBLSPublicKey and always use BytesToBLSPublicKey which is the cached version.

Tested locally.

@rlan35 rlan35 changed the title Remove expensive bls key serialization code Remove expensive bls key serialization code and use the cached version Jul 14, 2020
@@ -261,8 +263,10 @@ func (s *PublicBlockChainAPI) GetBlockSigners(ctx context.Context, blockNr rpc.B
if err != nil {
return nil, err
}
blsPublicKey := new(bls.PublicKey)
validator.BLSPublicKey.ToLibBLSPublicKey(blsPublicKey)
blsPublicKey := new(bls_core.PublicKey)
Copy link
Contributor

@gupadhyaya gupadhyaya Jul 15, 2020

Choose a reason for hiding this comment

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

these allocations are not necessary right? can you remove it throughout?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it is needed if you want to inline the error check. It shouldn't have performance difference as anyway a new pointer needs to be allocated. So I will leave as is.

@rlan35 rlan35 merged commit bdd2a58 into harmony-one:main Jul 15, 2020
@rlan35
Copy link
Contributor Author

rlan35 commented Jul 15, 2020

This PR reduced block sync time for beacon chain from around 0.5s to around 0.25s per block

@rlan35
Copy link
Contributor Author

rlan35 commented Jul 15, 2020

CPU usage before this PR:
image

After this PR:
image

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