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

Faster trie node encoding updated #1974

Merged
merged 1 commit into from Oct 13, 2023

Conversation

blukat29
Copy link
Contributor

@blukat29 blukat29 commented Sep 19, 2023

Proposed changes

Continuation of #1679.

  • Replace rlp.EncodeToBytes() with concrete node.encode() to avoid type reflection.

Types of changes

  • Bugfix
  • New feature or enhancement
  • Others

Checklist

  • I have read the CONTRIBUTING GUIDELINES doc
  • I have signed the CLA
  • Lint and unit tests pass locally with my changes ($ make test)
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • Any dependent changes have been merged and published in downstream modules

Related issues

Further comments

Running time 16% and memalloc 2% decreased.

cd storage/statedb
git checkout dev
go test -v -run=^$ -bench=BenchmarkHashFixedSize -count=7 | tee before.txt
git checkout faster-trie-node-encode
go test -v -run=^$ -bench=BenchmarkHashFixedSize -count=7 | tee after.txt
benchstat before.txt after.txt

goos: darwin
goarch: arm64
pkg: github.com/klaytn/klaytn/storage/statedb
                      │ before.txt  │             after.txt              │
                      │   sec/op    │   sec/op     vs base               │
HashFixedSize/10-10     74.53µ ± 1%   65.24µ ± 3%  -12.47% (p=0.001 n=7)
HashFixedSize/100-10    199.3µ ± 1%   156.8µ ± 3%  -21.33% (p=0.001 n=7)
HashFixedSize/1K-10     1.393m ± 2%   1.206m ± 4%  -13.38% (p=0.001 n=7)
HashFixedSize/10K-10    8.803m ± 1%   7.296m ± 3%  -17.12% (p=0.001 n=7)
HashFixedSize/100K-10   76.55m ± 3%   62.78m ± 5%  -17.99% (p=0.001 n=7)
geomean                 1.694m        1.414m       -16.52%

                      │  before.txt  │              after.txt              │
                      │     B/op     │     B/op      vs base               │
HashFixedSize/10-10     34.83Ki ± 0%   30.86Ki ± 0%  -11.38% (p=0.001 n=7)
HashFixedSize/100-10    168.1Ki ± 0%   149.5Ki ± 0%  -11.08% (p=0.001 n=7)
HashFixedSize/1K-10     1.644Mi ± 0%   1.456Mi ± 0%  -11.44% (p=0.001 n=7)
HashFixedSize/10K-10    17.11Mi ± 0%   15.03Mi ± 0%  -12.12% (p=0.001 n=7)
HashFixedSize/100K-10   169.8Mi ± 0%   149.3Mi ± 0%  -12.07% (p=0.001 n=7)
geomean                 1.928Mi        1.704Mi       -11.62%

                      │ before.txt  │             after.txt             │
                      │  allocs/op  │  allocs/op   vs base              │
HashFixedSize/10-10      630.0 ± 0%    616.0 ± 0%  -2.22% (p=0.001 n=7)
HashFixedSize/100-10    3.079k ± 0%   3.012k ± 0%  -2.18% (p=0.001 n=7)
HashFixedSize/1K-10     30.60k ± 0%   29.91k ± 0%  -2.26% (p=0.001 n=7)
HashFixedSize/10K-10    310.7k ± 0%   303.1k ± 0%  -2.44% (p=0.001 n=7)
HashFixedSize/100K-10   3.102M ± 0%   3.027M ± 0%  -2.41% (p=0.001 n=7)
geomean                 35.60k        34.78k       -2.30%

@blukat29 blukat29 marked this pull request as ready for review September 19, 2023 09:29
@blukat29 blukat29 self-assigned this Sep 19, 2023
@blukat29 blukat29 mentioned this pull request Sep 20, 2023
9 tasks
@blukat29 blukat29 merged commit f57f72f into klaytn:dev Oct 13, 2023
11 checks passed
@blukat29 blukat29 deleted the faster-trie-node-encode branch October 13, 2023 01:55
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.

None yet

5 participants