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

Speedup log2 code #7106

Merged
merged 2 commits into from
Dec 13, 2023
Merged

Speedup log2 code #7106

merged 2 commits into from
Dec 13, 2023

Conversation

ValarDragon
Copy link
Member

State compatible logic to speedup the Log base 2 code, which appears in TWAPs.

This causes CPU usage for many wasm contracts, and EndBlock in updating TWAPs. Will further work to having this get computed when interpolating records for arithmetic TWAPs.

This PR takes the log2 code on my machine from:

BenchmarkLog2-12              7803            261769 ns/op           85620 B/op       1641 allocs/op

to

BenchmarkLog2-12    	    9193	    143944 ns/op	   43454 B/op	     605 allocs/op

So almost halving the CPU time, halving the I/O writes, and drastically reducing the number of allocs!

Not seeing any other obvious wins, beyond changing data type/algorithm as the bottleneck is now mulmut

Copy link
Contributor

Important Notice

This PR modifies an in-repo Go module. It is one of:

  • osmomath
  • osmoutils
  • x/ibc-hooks
  • x/epochs

The dependent Go modules, especially the root one, will have to be
updated to reflect the changes. Failing to do so might cause e2e to fail.

Please follow the instructions below:

  1. Open https://github.com/osmosis-labs/osmosis/actions/workflows/go-mod-auto-bump.yml
  2. Provide the current branch name
  3. On success, confirm if an automated commit corretly updated the go.mod and go.sum files

Please let us know if you need any help.

@ValarDragon ValarDragon added V:state/compatible/backport State machine compatible PR, should be backported A:no-changelog A:backport/v20.x backport patches to v20.x branch A:backport/v21.x backport patches to v21.x branch labels Dec 13, 2023
@ValarDragon ValarDragon merged commit fc3ccf2 into main Dec 13, 2023
1 check passed
@ValarDragon ValarDragon deleted the dev/speedup_log_code branch December 13, 2023 12:48
mergify bot pushed a commit that referenced this pull request Dec 13, 2023
* Speedup log2 code

* Update changelog

(cherry picked from commit fc3ccf2)
mergify bot pushed a commit that referenced this pull request Dec 13, 2023
* Speedup log2 code

* Update changelog

(cherry picked from commit fc3ccf2)
p0mvn pushed a commit that referenced this pull request Dec 14, 2023
* Speedup log2 code

* Update changelog

(cherry picked from commit fc3ccf2)

Co-authored-by: Dev Ojha <[email protected]>
p0mvn pushed a commit that referenced this pull request Dec 14, 2023
* Speedup log2 code

* Update changelog

(cherry picked from commit fc3ccf2)

Co-authored-by: Dev Ojha <[email protected]>
ValarDragon added a commit that referenced this pull request Dec 22, 2023
* Speedup log2 code

* Update changelog

(cherry picked from commit fc3ccf2)

Co-authored-by: Dev Ojha <[email protected]>
ValarDragon added a commit that referenced this pull request Dec 22, 2023
* Speedup log2 code

* Update changelog

(cherry picked from commit fc3ccf2)

Co-authored-by: Dev Ojha <[email protected]>
@github-actions github-actions bot mentioned this pull request Apr 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 A:no-changelog 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