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 more stable swap math operations #7214

Merged
merged 8 commits into from
Jan 2, 2024

Conversation

ValarDragon
Copy link
Member

@ValarDragon ValarDragon commented Dec 27, 2023

Speedup more stableswap math operations. Anticipated 2% speedup to CPU time of syncing

@ValarDragon ValarDragon added V:state/compatible/backport State machine compatible PR, should be backported A:no-changelog A:backport/v21.x backport patches to v21.x branch labels Dec 27, 2023
@github-actions github-actions bot added the C:x/gamm Changes, features and bugs related to the gamm module. label Dec 27, 2023
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.

@czarcas7ic
Copy link
Member

It seems the failed test is related to the change, will wait to review until passing, unless you want me to look into it @ValarDragon

@ValarDragon
Copy link
Member Author

Fixed!

Copy link
Member

@mattverse mattverse left a comment

Choose a reason for hiding this comment

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

ACK 🌮

osmomath/decimal.go Outdated Show resolved Hide resolved
@@ -63,15 +63,16 @@ func targetKCalculator(x0, y0, w, yf osmomath.BigDec) osmomath.BigDec {
// $$k_{iter}(x_f) = -x_{out}^3 + 3 x_0 x_{out}^2 - (y_f^2 + w + 3x_0^2)x_{out}$$
// where x_out = x_0 - x_f
func iterKCalculator(x0, w, yf osmomath.BigDec) func(osmomath.BigDec) osmomath.BigDec {
// compute coefficients first
cubicCoeff := osmomath.OneBigDec().Neg()
// compute coefficients first. Notice that the leading coefficient is -1, we will use this to compute faster.
Copy link
Member

Choose a reason for hiding this comment

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

note to other reviewers: x_{out}^3 remains same

@ValarDragon ValarDragon merged commit 9cd7231 into main Jan 2, 2024
1 check passed
@ValarDragon ValarDragon deleted the dev/speedup_more_mutative_stableswap_ops branch January 2, 2024 21:46
mergify bot pushed a commit that referenced this pull request Jan 2, 2024
* Speedup more stable swap math operations

* Try another speedup

* revert one sigfig change

* remove one more mutative operation

* update osmomath

* Update osmomath one more tiome

* Update osmomath/decimal.go

Co-authored-by: Matt, Park <[email protected]>

---------

Co-authored-by: Matt, Park <[email protected]>
(cherry picked from commit 9cd7231)

# Conflicts:
#	go.mod
#	go.sum
#	osmomath/decimal.go
#	osmomath/decimal_test.go
mattverse added a commit that referenced this pull request Jan 9, 2024
* Speedup more stable swap math operations (#7214)

* Speedup more stable swap math operations

* Try another speedup

* revert one sigfig change

* remove one more mutative operation

* update osmomath

* Update osmomath one more tiome

* Update osmomath/decimal.go

Co-authored-by: Matt, Park <[email protected]>

---------

Co-authored-by: Matt, Park <[email protected]>
(cherry picked from commit 9cd7231)

# Conflicts:
#	go.mod
#	go.sum
#	osmomath/decimal.go
#	osmomath/decimal_test.go

* fix conflicts (still need to run action)

* fix go mods to run script

* go mod updates v21 instead of main

---------

Co-authored-by: Dev Ojha <[email protected]>
Co-authored-by: Adam Tucker <[email protected]>
Co-authored-by: Adam Tucker <[email protected]>
Co-authored-by: mattverse <[email protected]>
@github-actions github-actions bot mentioned this pull request Jan 15, 2024
@github-actions github-actions bot mentioned this pull request May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:backport/v21.x backport patches to v21.x branch A:no-changelog C:x/gamm Changes, features and bugs related to the gamm module. V:state/compatible/backport State machine compatible PR, should be backported
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants