Closed icexin closed 3 years ago
Merging #229 (2812d64) into master (9042b75) will increase coverage by
0.18%
. The diff coverage is85.71%
.
@@ Coverage Diff @@
## master #229 +/- ##
==========================================
+ Coverage 47.39% 47.58% +0.18%
==========================================
Files 133 133
Lines 11413 11429 +16
==========================================
+ Hits 5409 5438 +29
+ Misses 4869 4856 -13
Partials 1135 1135
Impacted Files | Coverage Δ | |
---|---|---|
bcs/ledger/xledger/ledger/ledger_hash.go | 44.00% <85.71%> (+7.30%) |
:arrow_up: |
bcs/consensus/tdpos/tdpos.go | 40.96% <0.00%> (-0.81%) |
:arrow_down: |
kernel/consensus/base/driver/chained-bft/smr.go | 50.46% <0.00%> (+0.92%) |
:arrow_up: |
bcs/ledger/xledger/ledger/ledger.go | 56.82% <0.00%> (+0.97%) |
:arrow_up: |
bcs/network/p2pv1/conn.go | 61.29% <0.00%> (+6.45%) |
:arrow_up: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update 9042b75...2812d64. Read the comment docs.
Description
What is the purpose of the change?
减少merkle算法的内存分配
一个区块里面的交易多了之后,生成默克尔树就比较耗时,这个提交减少了内存分配的次数,内存分配主要在sha256的生成上,每个double sha256都要进行2次分配。
这个PR使用了arena分配算法,一次性申请够所有的内存,再在每次计算sha256的时候单独分配, 另外使用了零分配的sha256函数来辅助计算sha256
修复前:
修复后:
对于一个
10000
个交易的区块,内存分配次数从30017
降到了5
Type of change
Please delete options that are not relevant.