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 #1679

Closed
wants to merge 22 commits into from

Conversation

hqjang-pepper
Copy link
Contributor

@hqjang-pepper hqjang-pepper commented Nov 9, 2022

Proposed changes

Types of changes

Please put an x in the boxes related to your change.

  • Bugfix
  • New feature or enhancement
  • Others

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • 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

  • Please leave the issue numbers or links related to this PR here.

Further comments

If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...

@hqjang-pepper hqjang-pepper added the draft More implementation is needed label Nov 9, 2022
@hqjang-pepper hqjang-pepper added this to the v1.10 (Kore) milestone Nov 9, 2022
@hqjang-pepper hqjang-pepper self-assigned this Nov 9, 2022
@hqjang-pepper hqjang-pepper marked this pull request as draft November 9, 2022 06:34
@hqjang-pepper hqjang-pepper changed the title Fast trie node encoder Faster trie node encoding Nov 9, 2022
@hqjang-pepper hqjang-pepper marked this pull request as ready for review November 11, 2022 08:50
@hqjang-pepper hqjang-pepper removed the draft More implementation is needed label Nov 13, 2022
@hqjang-pepper
Copy link
Contributor Author

hqjang-pepper commented Nov 14, 2022

Benchmark test result
Before : dev branch
after : applying #1659 + #1656 + #1679

  • hash
before
BenchmarkHashFixedSize
BenchmarkHashFixedSize/10
BenchmarkHashFixedSize/10-10 	           27930	     42784 ns/op	   14004 B/op	     157 allocs/op
BenchmarkHashFixedSize/100
BenchmarkHashFixedSize/100-10         	   10000	    100930 ns/op	   65665 B/op	     777 allocs/op
BenchmarkHashFixedSize/1K
BenchmarkHashFixedSize/1K-10          	    1232	    982107 ns/op	  657792 B/op	    7784 allocs/op
BenchmarkHashFixedSize/10K
BenchmarkHashFixedSize/10K-10         	     277	   4412435 ns/op	 6906100 B/op	   79662 allocs/op
BenchmarkHashFixedSize/100K
BenchmarkHashFixedSize/100K-10        	      30	  40766426 ns/op	68241484 B/op	  794507 allocs/op

after
BenchmarkHashFixedSize
BenchmarkHashFixedSize/10
BenchmarkHashFixedSize/10-10 	           60531	     19774 ns/op	   10030 B/op	     142 allocs/op
BenchmarkHashFixedSize/100
BenchmarkHashFixedSize/100-10         	   16846	     71875 ns/op	   49463 B/op	     708 allocs/op
BenchmarkHashFixedSize/1K
BenchmarkHashFixedSize/1K-10          	    1630	    732230 ns/op	  500323 B/op	    7099 allocs/op
BenchmarkHashFixedSize/10K
BenchmarkHashFixedSize/10K-10         	     402	   2987934 ns/op	 5238605 B/op	   73313 allocs/op
BenchmarkHashFixedSize/100K
BenchmarkHashFixedSize/100K-10        	      44	  27326826 ns/op	51688571 B/op	  730456 allocs/op
  • commit
before
BenchmarkCommitAfterHashFixedSize
BenchmarkCommitAfterHashFixedSize/10
BenchmarkCommitAfterHashFixedSize/10-10 	           30988	     38790 ns/op	   36083 B/op	     208 allocs/op
BenchmarkCommitAfterHashFixedSize/100
BenchmarkCommitAfterHashFixedSize/100-10         	    8286	    145892 ns/op	  174370 B/op	    1022 allocs/op
BenchmarkCommitAfterHashFixedSize/1K
BenchmarkCommitAfterHashFixedSize/1K-10          	     828	   1485660 ns/op	 1701478 B/op	   10143 allocs/op
BenchmarkCommitAfterHashFixedSize/10K
BenchmarkCommitAfterHashFixedSize/10K-10         	      74	  14636495 ns/op	18696716 B/op	  103985 allocs/op
BenchmarkCommitAfterHashFixedSize/100K
BenchmarkCommitAfterHashFixedSize/100K-10        	       7	 148162095 ns/op	180172019 B/op	 1038887 allocs/op


after
BenchmarkCommitAfterHashFixedSize
BenchmarkCommitAfterHashFixedSize/10
BenchmarkCommitAfterHashFixedSize/10-10 	           60642	     19199 ns/op	   30901 B/op	     189 allocs/op
BenchmarkCommitAfterHashFixedSize/100
BenchmarkCommitAfterHashFixedSize/100-10         	   10000	    101429 ns/op	  151283 B/op	     918 allocs/op
BenchmarkCommitAfterHashFixedSize/1K
BenchmarkCommitAfterHashFixedSize/1K-10          	    1005	   1194671 ns/op	 1473326 B/op	    9108 allocs/op
BenchmarkCommitAfterHashFixedSize/10K
BenchmarkCommitAfterHashFixedSize/10K-10         	      93	  11931540 ns/op	16366578 B/op	   93858 allocs/op
BenchmarkCommitAfterHashFixedSize/100K
BenchmarkCommitAfterHashFixedSize/100K-10        	       9	 118098787 ns/op	157060696 B/op	  937584 allocs/op

@hqjang-pepper
Copy link
Contributor Author

  • hash
    • operation : 48 ~ 26% faster
    • alloc : 5% less
  • commit
    • operation : 20~50% faster
    • alloc: 10% less

@hqjang-pepper
Copy link
Contributor Author

DeriveShaOrig benchmark Test - using stackTrie
before : v 1.9.1
after : applying #1659 + #1656 + #1679 + #1648 (optimize derivesha)

Before this PR : 
BenchmarkDeriveShaOrig/100test-stackTrie-10         	    7977	    148040 ns/op
BenchmarkDeriveShaOrig/1000test-stackTrie-10         	     744	   1533285 ns/op
BenchmarkDeriveShaOrig/4000test-stackTrie-10         	     194	   5926051 ns/op


After this PR :
BenchmarkDeriveShaOrig/100test-stackTrie-10         	    9498	    121794 ns/op
BenchmarkDeriveShaOrig/1000test-stackTrie-10         	     968	   1234340 ns/op
BenchmarkDeriveShaOrig/4000test-stackTrie-10         	     243	   4800326 ns/op

comparing with other deriveSha implementation

BenchmarkDeriveSha
BenchmarkDeriveSha/Concat,4000
BenchmarkDeriveSha/Concat,4000-10         	     375	   3036499 ns/op
BenchmarkDeriveSha/Orig,4000
BenchmarkDeriveSha/Orig,4000-10           	     238	   4893403 ns/op
BenchmarkDeriveSha/Simple,4000
BenchmarkDeriveSha/Simple,4000-10         	     207	   5601969 ns/op

BenchmarkDeriveShaSingleAccount/Concat
BenchmarkDeriveShaSingleAccount/Concat-10         	     385	   3032999 ns/op
BenchmarkDeriveShaSingleAccount/Orig
BenchmarkDeriveShaSingleAccount/Orig-10           	     238	   5134026 ns/op
BenchmarkDeriveShaSingleAccount/Simple
BenchmarkDeriveShaSingleAccount/Simple-10         	     193	   6258522 ns/op

@kjhman21 kjhman21 modified the milestones: v1.10 (Kore), v1.11 (Mantle) Nov 21, 2022
@aidan-kwon aidan-kwon marked this pull request as draft July 18, 2023 03:38
@aidan-kwon aidan-kwon removed this from the v1.11.0 milestone Jul 24, 2023
@blukat29 blukat29 mentioned this pull request Sep 19, 2023
9 tasks
@blukat29
Copy link
Contributor

Replaced by #1974.

@blukat29 blukat29 closed this Sep 20, 2023
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

4 participants