OpenAtomFoundation / xupercore

The kernel of xuperchain.
Apache License 2.0
61 stars 47 forks source link

lib: fix log performance #228

Closed icexin closed 3 years ago

icexin commented 3 years ago

Description

rand.Seed在并发的场景下有全局锁,构造日志对象的时候使用rand.Seed来生成唯一id,这会造成性能问题,只用全局初始化一次即可。

同时修复了badgerdb的编译问题

修复前:

BenchmarkGenId-160         81132             14739 ns/op

修复后:

BenchmarkGenId-160       1000000              1113 ns/op

差不多提升了12倍

Type of change

codecov-commenter commented 3 years ago

Codecov Report

Merging #228 (88035ed) into master (9042b75) will increase coverage by 0.02%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #228      +/-   ##
==========================================
+ Coverage   47.39%   47.41%   +0.02%     
==========================================
  Files         133      133              
  Lines       11413    11411       -2     
==========================================
+ Hits         5409     5411       +2     
+ Misses       4869     4866       -3     
+ Partials     1135     1134       -1     
Impacted Files Coverage Δ
bcs/network/p2pv2/filter.go 36.84% <ø> (+0.94%) :arrow_up:
lib/utils/utils.go 53.65% <ø> (-1.11%) :arrow_down:
lib/logs/log.go 60.00% <100.00%> (ø)
kernel/consensus/base/driver/chained-bft/smr.go 50.46% <0.00%> (+0.92%) :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...88035ed. Read the comment docs.