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

Optimize crypto #3174

Merged
merged 7 commits into from
Mar 7, 2024
Merged

Conversation

Ashuaidehao
Copy link
Contributor

@Ashuaidehao Ashuaidehao commented Mar 5, 2024

Description

Cahced crypto object could optimize verify signature performance。

Fixes # (no related)

Type of change

  • Optimize

How Has This Been Tested?

Syncing blocks speed up about 25%.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Copy link
Member

@vncoelho vncoelho left a comment

Choose a reason for hiding this comment

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

Looks good and a simple change.
Can you check @superboyiii ?

Jim8y
Jim8y previously approved these changes Mar 5, 2024
@Jim8y
Copy link
Contributor

Jim8y commented Mar 5, 2024

This is already tested by @superboyiii .

Copy link
Contributor

@roman-khimov roman-khimov left a comment

Choose a reason for hiding this comment

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

It looks similar to ECPointCache, but at another level. Not sure why this can be a problem for C# (it takes time to calculate Y, here you already have it), but if it works (in a size-limited fashion of course) and gives measurable difference, then OK.

src/Neo/Cryptography/Crypto.cs Outdated Show resolved Hide resolved
Copy link
Member

@shargon shargon left a comment

Choose a reason for hiding this comment

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

Use FIFOCache instead of regular dictionary?

@Ashuaidehao
Copy link
Contributor Author

Ashuaidehao commented Mar 5, 2024

Use FIFOCache instead of regular dictionary?

We can change it to FIFOCache with a large limit. If the limit was small, the performance maybe more lower than no cache.
Or we can change it to time-out cache?

@Ashuaidehao Ashuaidehao closed this Mar 5, 2024
@Ashuaidehao Ashuaidehao reopened this Mar 5, 2024
@roman-khimov
Copy link
Contributor

with a large limit

To me it's still very, very similar to ECPointCache, so I'd use the same limit by default. Most of ECPoint uses is for verification anyway, so hitting one cache but not hitting the other is suboptimal to me.

Copy link
Member

@vncoelho vncoelho left a comment

Choose a reason for hiding this comment

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

@superboyiii ,can you check the performance difference when syncing?

@vncoelho
Copy link
Member

vncoelho commented Mar 5, 2024

If it is 25% as described we can merge now and later modify with other suggestions.

@Jim8y
Copy link
Contributor

Jim8y commented Mar 5, 2024

@superboyiii ,can you check the performance difference when syncing?

Its 25% - 30% performance increase from the benchmark. But its for syncing the chain.

@vncoelho
Copy link
Member

vncoelho commented Mar 5, 2024

@superboyiii ,can you check the performance difference when syncing?

Its 25% - 30% performance increase from the benchmark. But its for syncing the chain.

Very good,did u also replicate this result?

@shargon shargon added the Bug Used to tag confirmed bugs label Mar 6, 2024
shargon
shargon previously approved these changes Mar 6, 2024
@shargon
Copy link
Member

shargon commented Mar 6, 2024

I found a bug in ECPoint comparation, it doesn't take care about the curve, now it should work

Copy link
Contributor

@roman-khimov roman-khimov left a comment

Choose a reason for hiding this comment

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

Tests failing, can't be merged.

@shargon
Copy link
Member

shargon commented Mar 6, 2024

Tests failing, can't be merged.

The test checked that the bug was fine xD

@superboyiii
Copy link
Member

@superboyiii ,can you check the performance difference when syncing?

Yes, it's almost 30% speed up.

@shargon shargon merged commit 199ffee into neo-project:master Mar 7, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Used to tag confirmed bugs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants