-
Notifications
You must be signed in to change notification settings - Fork 610
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
PowApprox mutable internal logic #324
Conversation
x/gamm/keeper/math.go
Outdated
term = term.Mul(c.Mul(x)) | ||
term = term.Quo(bigK) | ||
for i := int64(1); term.GTE(precision); i++ { | ||
a.Set(exp) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whats going on with a.Set(exp)
and bigK
. These don't seem the same across the update
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought absDifferenceWithSign
was mutable but it isn't, will fix this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually we could gain speed if we make abs
mutable.
goos: darwin
goarch: amd64
pkg: github.com/osmosis-labs/osmosis/x/gamm/keeper
cpu: Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
BenchmarkPow 20 67177389 ns/op 33736621 B/op 970000 allocs/op
BenchmarkPow-2 19 59532866 ns/op 33737600 B/op 970008 allocs/op
BenchmarkPow-4 19 57907179 ns/op 33739167 B/op 970019 allocs/op
BenchmarkPow-8 20 58669216 ns/op 33741359 B/op 970028 allocs/op
BenchmarkPow-16 19 58099349 ns/op 33745091 B/op 970036 allocs/op
BenchmarkSqrtPow 64537 16292 ns/op 7384 B/op 309 allocs/op
BenchmarkSqrtPow-2 80757 14496 ns/op 7384 B/op 309 allocs/op
BenchmarkSqrtPow-4 78423 15511 ns/op 7384 B/op 309 allocs/op
BenchmarkSqrtPow-8 78834 14515 ns/op 7384 B/op 309 allocs/op
BenchmarkSqrtPow-16 83053 14379 ns/op 7384 B/op 309 allocs/op |
Awesome, so it is like a 2x speed improvement!(Also the thing with heap improvements is that they are more impactful as he overall memory situation gets worse. Lets sync with Sunny whether this gets merged today, or like this weekend in a version that just makes nodes faster |
Codecov Report
@@ Coverage Diff @@
## main #324 +/- ##
=======================================
Coverage 18.28% 18.28%
=======================================
Files 133 133
Lines 21471 21473 +2
=======================================
+ Hits 3925 3927 +2
Misses 16891 16891
Partials 655 655
Continue to review full report at Codecov.
|
closes: #56