Files
cosmos-sdk/types
Emmanuel T OdekeandAlessio Treglia 929b62cd46 types: intern AccAddress.String() to gut wasted expensive recomputations (#8694)
Given that AccAddress is a []byte type, and its .String() method is
quite expensive, continuously invoking the method doesn't easily provide
a way for the result to be memoized. In memory profiles from
benchmarking OneBankSendTxPerBlock and run for a while, it showed >2GiB burnt
and SendCoins consuming a bunch of memory: >2GiB.

This change introduces a simple global cache with a map to intern
AccAddress values, so that we quickly look up the expensively computed
values. With it, the prior memory profiles are erased, and benchmarks
show improvements:

```shell
$ benchstat before.txt after.txt
name                     old time/op    new time/op    delta
OneBankSendTxPerBlock-8    1.94ms ± 9%    1.92ms ±11%   -1.34%  (p=0.011 n=58+57)

name                     old alloc/op   new alloc/op   delta
OneBankSendTxPerBlock-8     428kB ± 0%     365kB ± 0%  -14.67%  (p=0.000 n=58+54)

name                     old allocs/op  new allocs/op  delta
OneBankSendTxPerBlock-8     6.34k ± 0%     5.90k ± 0%   -7.06%  (p=0.000 n=58+57)
```

Fixes #8693

Co-authored-by: Alessio Treglia <alessio@tendermint.com>
2021-02-25 03:01:03 -08:00
..
2021-02-23 08:46:01 +00:00
2021-02-23 08:46:01 +00:00
2021-02-19 15:02:53 +00:00
2020-08-14 13:58:53 -04:00
2021-02-23 08:46:01 +00:00
2021-02-23 08:46:01 +00:00
2020-12-04 15:06:50 +00:00
2020-05-08 08:46:12 +00:00
2020-09-22 19:46:48 -04:00
2020-12-04 15:06:50 +00:00
2021-02-23 08:46:01 +00:00
2020-08-14 13:58:53 -04:00