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

core: reduce big.Int copies #99

Merged
merged 1 commit into from
Mar 23, 2018
Merged

core: reduce big.Int copies #99

merged 1 commit into from
Mar 23, 2018

Conversation

jmank88
Copy link
Contributor

@jmank88 jmank88 commented Mar 23, 2018

pprof memprofile for BenchmarkStateProcessor_Process showed (*stateObject).Setbalance accounting for 4% of alloc_space and 9.7% of alloc_objects:

190.01MB  4.06% 48.68%   291.52MB  6.23%  github.com/gochain-io/gochain/core/state.(*stateObject).SetBalance

5869752  9.70% 22.57%    7936219 13.12%  github.com/gochain-io/gochain/core/state.(*stateObject).SetBalance

The big.Int copy responsible for the allocations isn't necessary, since the copied field is set in the method call on the next line.
Here are benchcmp results after removing the copy:

benchmark                                    old ns/op      new ns/op      delta
BenchmarkStateProcessor_Process/____1-4      75714          71901          -5.04%
BenchmarkStateProcessor_Process/___10-4      188055         183828         -2.25%
BenchmarkStateProcessor_Process/__100-4      1313477        1298224        -1.16%
BenchmarkStateProcessor_Process/_1000-4      12085332       12429412       +2.85%
BenchmarkStateProcessor_Process/_10000-4     1564422395     1135580047     -27.41%

benchmark                                    old allocs     new allocs     delta
BenchmarkStateProcessor_Process/____1-4      253            244            -3.56%
BenchmarkStateProcessor_Process/___10-4      1243           1144           -7.96%
BenchmarkStateProcessor_Process/__100-4      11143          10144          -8.97%
BenchmarkStateProcessor_Process/_1000-4      110145         102152         -7.26%
BenchmarkStateProcessor_Process/_10000-4     1462026        1369251        -6.35%

benchmark                                    old bytes     new bytes     delta
BenchmarkStateProcessor_Process/____1-4      44579         44225         -0.79%
BenchmarkStateProcessor_Process/___10-4      93326         89372         -4.24%
BenchmarkStateProcessor_Process/__100-4      580901        540950        -6.88%
BenchmarkStateProcessor_Process/_1000-4      5456650       5216035       -4.41%
BenchmarkStateProcessor_Process/_10000-4     79498328      76030176      -4.36%

@jmank88 jmank88 requested a review from treeder March 23, 2018 14:15
@treeder treeder merged commit d47f66b into master Mar 23, 2018
@treeder treeder deleted the set-bal branch March 23, 2018 14:17
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

2 participants