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 Sstore operation execution time #4836

Merged
merged 6 commits into from
Dec 23, 2022

Conversation

ahamlat
Copy link
Contributor

@ahamlat ahamlat commented Dec 18, 2022

Signed-off-by: Ameziane H ameziane.hamlat@consensys.net

PR description

This PR aims to improve SStore operation execution time by getting the original value and current value only once during gas cost and refund calculation. Currently, we make these two calls twice, and even with RocksDB cache, this has an impact on SStore performance as we can see in the CPU profiling flame graph below.
image

After this PR, we can see that getSorageValue (get current value) and getOriginalStorageValue are called only once.
image

Fixed Issue(s)

Documentation

  • I thought about documentation and added the doc-change-required label to this PR if
    updates are required.

Changelog

…once.

Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net>
Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net>
@ahamlat ahamlat changed the title [Work In Progress] Optimize Sstore operation execution time Optimize Sstore operation execution time Dec 18, 2022
…forks)

Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net>
@ahamlat ahamlat marked this pull request as ready for review December 20, 2022 18:58
Copy link
Contributor

@shemnon shemnon left a comment

Choose a reason for hiding this comment

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

The CodeQL warnings all appear legitimage, so please address them.

As this is changing an API on an interface it will be a breaking change and will need to land in 23.1.0-beta and not be cherry picked into 22.10.4.
Also, add a changelog entry under breaking changes.

Copy link
Contributor

@garyschulte garyschulte left a comment

Choose a reason for hiding this comment

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

👍 just one nitpick about omitting final for local variables in gas calculators. Perhaps you had a reason to omit final?

nice that the gas calculator signatures can be simplified also.

…HANGELOG.md

Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net>
@ahamlat ahamlat merged commit 3ecb09d into hyperledger:main Dec 23, 2022
macfarla pushed a commit to macfarla/besu that referenced this pull request Jan 10, 2023
* Optimize Sstore operation, get current value and original value only once.
Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net>

* Fix javadoc.

Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net>

* refactoring (add a supplier implementation to better support all the forks)

Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net>

* delete unnecessary parameters, add final for some fields and modify CHANGELOG.md

Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net>

* add a missing parameter in Javadoc

Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net>

Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net>
Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com>
eum602 pushed a commit to lacchain/besu that referenced this pull request Nov 3, 2023
* Optimize Sstore operation, get current value and original value only once.
Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net>

* Fix javadoc.

Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net>

* refactoring (add a supplier implementation to better support all the forks)

Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net>

* delete unnecessary parameters, add final for some fields and modify CHANGELOG.md

Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net>

* add a missing parameter in Javadoc

Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net>

Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net>
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.

3 participants