Skip to content

Add mutative in place operations to decimal types #9046

Closed
@ValarDragon

Description

Summary

Currently all decimal operations allocate a new big int in memory. This is a very large performance hit for math-intensive operations. We should add operations such as add_in_place, mul_in_place, and quo_in_place to give developers the ability to get faster arithmetic should they need it.

This will keep the default code as immutable, so only developers who need this feature would themselves opt-into it.

Problem Definition

Allocating memory on each operation becomes an important speed pain-point for math intensive operations. This is 40% of the time for the Osmosis approximate power algorithm (Thanks to @Thunnini for finding this out)

osmosis-labs/osmosis#56

Proposal

Add add_in_place, mul_in_place, sub_in_place, neg_in_place and quo_in_place operations to sdk.Dec.


For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions