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

x/incentives: Lower Epoch allocation overhead #7100

Merged
merged 2 commits into from
Dec 12, 2023
Merged

Conversation

ValarDragon
Copy link
Member

The IAVL v2 benchmarks were showing Memory allocation as a significant chunk of the CPU time. (NOTE: CacheKV and DB overheads that are mainly applying to us in production are not shown in these benchmarks)

So looking at golang code, the capacity of a large slice grows by a factor of 1.25 every grow. So in the case where this is full / near full (most of the time), this would grow 3 or 4 times. 1.25**3 = 1.95, which involves expensive memcopies on top of extra allocations.

Hence this speeds up the relevant logic.

From the IAVL v2 benchmarks, this is ~30% of the CPU time of the Distribute function!

@ValarDragon ValarDragon added V:state/compatible/backport State machine compatible PR, should be backported A:backport/v20.x backport patches to v20.x branch A:backport/v21.x backport patches to v21.x branch labels Dec 12, 2023
@ValarDragon ValarDragon merged commit 63d2551 into main Dec 12, 2023
1 check passed
@ValarDragon ValarDragon deleted the dev/lower_alloc_time branch December 12, 2023 21:07
mergify bot pushed a commit that referenced this pull request Dec 12, 2023
* Lower allocation overhead

* Add changelog

(cherry picked from commit 63d2551)

# Conflicts:
#	CHANGELOG.md
mergify bot pushed a commit that referenced this pull request Dec 12, 2023
* Lower allocation overhead

* Add changelog

(cherry picked from commit 63d2551)
ValarDragon added a commit that referenced this pull request Dec 12, 2023
* Lower allocation overhead

* Add changelog

(cherry picked from commit 63d2551)

Co-authored-by: Dev Ojha <[email protected]>
ValarDragon added a commit that referenced this pull request Dec 13, 2023
* x/incentives: Lower Epoch allocation overhead (#7100)

* Lower allocation overhead

* Add changelog

(cherry picked from commit 63d2551)

# Conflicts:
#	CHANGELOG.md

* Fix changelog conflict

* Revert "Fix changelog conflict"

This reverts commit 6235a69.

* Fix Changelog.md

* try Alessandro's fix

---------

Co-authored-by: Dev Ojha <[email protected]>
Co-authored-by: Dev Ojha <[email protected]>
ValarDragon added a commit that referenced this pull request Dec 20, 2023
* Lower allocation overhead

* Add changelog

(cherry picked from commit 63d2551)

Co-authored-by: Dev Ojha <[email protected]>
ValarDragon added a commit that referenced this pull request Dec 21, 2023
* Lower allocation overhead

* Add changelog

(cherry picked from commit 63d2551)

Co-authored-by: Dev Ojha <[email protected]>
@github-actions github-actions bot mentioned this pull request Feb 1, 2024
@github-actions github-actions bot mentioned this pull request May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:backport/v20.x backport patches to v20.x branch A:backport/v21.x backport patches to v21.x branch C:x/incentives V:state/compatible/backport State machine compatible PR, should be backported
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants