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

osmomath: QuoTruncate with no reallocation #6428

Merged
merged 16 commits into from
Sep 20, 2023
Merged

osmomath: QuoTruncate with no reallocation #6428

merged 16 commits into from
Sep 20, 2023

Conversation

hieuvubk
Copy link
Contributor

Closes: #6370

What is the purpose of the change

QuoTruncate with no reallocation

Benchmark

OLD:
BenchmarkQuoTruncate-16          1781227               663.5 ns/op           448 B/op          6 allocs/op

NEW:
BenchmarkQuoTruncate-16         44712544                24.01 ns/op            0 B/op          0 allocs/op

Testing and Verifying

(Please pick one of the following options)

This change is a trivial rework / code cleanup without any test coverage.

(or)

This change is already covered by existing tests, such as (please describe tests).

(or)

This change added tests and can be verified as follows:

(example:)

  • Added unit test that validates ...
  • Added integration tests for end-to-end deployment with ...
  • Extended integration test for ...
  • Manually verified the change by ...

Documentation and Release Note

  • Does this pull request introduce a new feature or user-facing behavior changes?
  • Changelog entry added to Unreleased section of CHANGELOG.md?

Where is the change documented?

  • Specification (x/{module}/README.md)
  • Osmosis documentation site
  • Code comments?
  • N/A

@github-actions
Copy link
Contributor

github-actions bot commented Sep 18, 2023

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.

@hieuvubk hieuvubk marked this pull request as draft September 18, 2023 19:17
@hieuvubk hieuvubk added the V:state/compatible/no_backport State machine compatible PR, depends on prior breaks label Sep 19, 2023
@hieuvubk hieuvubk marked this pull request as ready for review September 19, 2023 08:40
osmomath/decimal.go Show resolved Hide resolved
osmomath/decimal_test.go Show resolved Hide resolved
x/concentrated-liquidity/math/math.go Show resolved Hide resolved
@p0mvn
Copy link
Member

p0mvn commented Sep 20, 2023

@hieuvubk please resolve one remaining conflict and we can merge this. Sorry for the break again - I'm merging a lot today

I reviewed calls to QuoTruncate and agree that we cannot optimize anything else

@p0mvn p0mvn merged commit 114f055 into main Sep 20, 2023
1 check passed
@p0mvn p0mvn deleted the hieu/quotruncate_mut branch September 20, 2023 20:06
@p0mvn p0mvn added V:state/breaking State machine breaking PR A:backport/v19.x backport patches to v19.x branch and removed V:state/compatible/no_backport State machine compatible PR, depends on prior breaks labels Sep 20, 2023
mergify bot pushed a commit that referenced this pull request Sep 20, 2023
* reduce reallocations of QuoTruncate

* separate funcs

* chopPrecisionAndTruncateMut

* changlog & go.mod

* mutative

* test

* go.mod

* go mod tidy

* update go.mod

* lack

* revert

* update go.mod

(cherry picked from commit 114f055)

# Conflicts:
#	CHANGELOG.md
#	go.mod
#	go.sum
#	x/concentrated-liquidity/math/math.go
@p0mvn
Copy link
Member

p0mvn commented Sep 20, 2023

I marked this PR as state-breaking despite backporting it so that we revisit this for a major upgrade.

The reason is that we cannot effectively test the backport since the only applications of the new QuoTruncateMut function are done to the new logic (post v19)

@p0mvn
Copy link
Member

p0mvn commented Sep 20, 2023

I marked this PR as state-breaking despite backporting it so that we revisit this for a major upgrade.

The reason is that we cannot effectively test the backport since the only applications of the new QuoTruncateMut function are done to the new logic (post v19)

Was able to still apply this change on the backport. See commit: b1fe95c

Therefore, test coverage should be sufficient

p0mvn added a commit that referenced this pull request Sep 20, 2023
* osmomath: QuoTruncate with no reallocation (backport #6428)

* updates

---------

Co-authored-by: roman <[email protected]>
@github-actions github-actions bot mentioned this pull request Apr 15, 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/v19.x backport patches to v19.x branch C:x/concentrated-liquidity V:state/breaking State machine breaking PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat(osmomath): introduce more mutative math helpers for BigDec
2 participants