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

Keccak perf #6999

Closed
wants to merge 7 commits into from
Closed

Keccak perf #6999

wants to merge 7 commits into from

Conversation

benaadams
Copy link
Member

@benaadams benaadams commented May 8, 2024

Changes

  • Avoid the copy in and copy out step by operating over same data. Since there are so many fields they spill to stack anyway (and is stackalloc'd array anyway to start), so operate with stack and remove two 200 byte copies, or 50 ulongs of memory shuffling

KeccakF asm

Before

; Total bytes of code 2606

After

; Total bytes of code 1942

Types of changes

What types of changes does your code introduce?

  • Optimization

Testing

Requires testing

  • No

Copy link
Member

@LukaszRozmej LukaszRozmej left a comment

Choose a reason for hiding this comment

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

Do you have any benchmarks?

Copy link
Member

@LukaszRozmej LukaszRozmej left a comment

Choose a reason for hiding this comment

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

Do you have any - even simple benchmark?

src/Nethermind/Nethermind.Core/Crypto/KeccakHash.cs Outdated Show resolved Hide resolved
@benaadams
Copy link
Member Author

Do you have any - even simple benchmark?

I benchmarked it with Paprika's benchamarks and it was pretty much the same 😢

There are two many varibles and too few registers so it spills to stack quite a lot and is very very sensitive to instruction order and data dependencies formed

@benaadams benaadams closed this May 16, 2024
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.

None yet

2 participants