Add mutative in place operations to decimal types #9046
Closed
Description
opened on Apr 2, 2021
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)
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