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

perf: memoize bech32 encoding and decoding #216

Merged
merged 5 commits into from
Jun 1, 2021
Merged

Conversation

wetcod
Copy link
Contributor

@wetcod wetcod commented Jun 1, 2021

Description

bech32 encoding and decoding takes a lot of time, so memoize it

It is appropriate to add a layer to choose whether to access the cache or to run actual conversion.
There are too many parts that call AccAddressFromBech32 or AccAddress.String (baseapp, most modules, Json marshaling, etc.)
I am concerned that there will be many changes, so it would be better to proceed later.

Profile

AS-IS

image
image

TO-BE

image
image

Because of the performance improvement of types.AccAddress.String and types.AccAddressFromBech32,
DeliverTx is faster

-->

closes: #XXXX


Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Targeted PR against correct branch (see CONTRIBUTING.md)
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the module structure standards.
  • Wrote unit and integration tests
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/)
  • Added relevant godoc comments.
  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer
  • Review Codecov Report in the comment section below once CI passes

@wetcod wetcod self-assigned this Jun 1, 2021
@codecov
Copy link

codecov bot commented Jun 1, 2021

Codecov Report

Merging #216 (870d1b7) into v2/develop (88ab1bd) will decrease coverage by 0.03%.
The diff coverage is n/a.

Impacted file tree graph

@@              Coverage Diff               @@
##           v2/develop     #216      +/-   ##
==============================================
- Coverage       53.49%   53.46%   -0.04%     
==============================================
  Files             653      652       -1     
  Lines           47376    47379       +3     
==============================================
- Hits            25343    25330      -13     
- Misses          19178    19187       +9     
- Partials         2855     2862       +7     
Impacted Files Coverage Δ
baseapp/baseapp.go 77.94% <ø> (+0.85%) ⬆️
server/config/config.go 42.39% <ø> (+0.63%) ⬆️
server/config/toml.go 18.18% <ø> (ø)
simapp/app.go 83.96% <ø> (+0.16%) ⬆️
simapp/simd/cmd/root.go 79.84% <ø> (-1.11%) ⬇️
store/cache/cache.go 88.88% <ø> (+0.65%) ⬆️
store/cachekv/store.go 91.34% <ø> (+4.21%) ⬆️
store/iavl/store.go 66.36% <ø> (+0.29%) ⬆️
store/rootmulti/store.go 65.25% <ø> (-0.72%) ⬇️
store/types/gas.go 75.00% <ø> (+1.82%) ⬆️
... and 24 more

types/address.go Outdated Show resolved Hide resolved
types/address.go Outdated Show resolved Hide resolved
@egonspace egonspace added this to the performance improvement milestone Jun 1, 2021
@wetcod wetcod requested a review from egonspace June 1, 2021 07:15
@egonspace
Copy link

Looks very good!

@wetcod wetcod merged commit f904f13 into v2/develop Jun 1, 2021
@wetcod wetcod deleted the memoize-bech32 branch June 1, 2021 07:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants