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: aminocompat: package to allow optimizations iff amino-compatible #16092

Closed
wants to merge 1 commit into from

Conversation

odeke-em
Copy link
Collaborator

Implements a function "AllClear" which checks that an object is amino-json compatible and iff all clear, can permit us to directly:

  • use encoding/json.Marshal

which produces sorted JSON

instead of 3 expensive steps to produce sorted JSON:

  • amino.MarshalJSON
  • encoding/json.Unmarshal
  • encoding/json.Marshal

and the results are stark

$ benchstat before.txt after.txt
name          old time/op    new time/op    delta
MsgDeposit-8    10.8µs ± 1%     1.3µs ± 1%  -87.55%  (p=0.000 n=10+8)

name          old alloc/op   new alloc/op   delta
MsgDeposit-8    3.75kB ± 0%    0.26kB ± 0%  -92.96%  (p=0.000 n=10+10)

name          old allocs/op  new allocs/op  delta
MsgDeposit-8      99.0 ± 0%      13.0 ± 0%  -86.87%  (p=0.000 n=10+10)

Updates #2350

/cc @elias-orijtech @ValarDragon @tac0turtle

Implements a function "AllClear" which checks that an object is
amino-json compatible and iff all clear, can permit us to directly:
* use encoding/json.Marshal

which produces sorted JSON

instead of 3 expensive steps to produce sorted JSON:
* amino.MarshalJSON
* encoding/json.Unmarshal
* encoding/json.Marshal

and the results are stark

```shell
$ benchstat before.txt after.txt
name          old time/op    new time/op    delta
MsgDeposit-8    10.8µs ± 1%     1.3µs ± 1%  -87.55%  (p=0.000 n=10+8)

name          old alloc/op   new alloc/op   delta
MsgDeposit-8    3.75kB ± 0%    0.26kB ± 0%  -92.96%  (p=0.000 n=10+10)

name          old allocs/op  new allocs/op  delta
MsgDeposit-8      99.0 ± 0%      13.0 ± 0%  -86.87%  (p=0.000 n=10+10)
```

Updates #2350
@github-actions
Copy link
Contributor

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the Stale label Jun 10, 2023
@github-actions github-actions bot closed this Jun 14, 2023
@odeke-em odeke-em deleted the aminocompat-skip-amino-json branch June 28, 2023 21:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant