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

Store blocks and transactions as bare files instead of embeded files in LiteDB #662

Merged
merged 11 commits into from Nov 13, 2019

Conversation

dahlia
Copy link
Contributor

@dahlia dahlia commented Nov 11, 2019

This makes blocks and transactions stored as bare files, instead of LiteDB's FileStorage. Therefore, now it cannot be called just LiteDBStore anymore, so I renamed it to DefaultStore. As more than a single file are made, it became to take a directory instead of a single file.

Note that this still has only a single LiteDB file yet. I'm going to make another patch to make each chain ID has its own LiteDB file.

Here are small and not-that-accurate benchmarks:

LiteDBStore (Linux)

BenchmarkDotNet=v0.11.5, OS=ubuntu 18.04
Intel Xeon CPU E5-2673 v4 2.30GHz, 1 CPU, 2 logical and 2 physical cores
.NET Core SDK=3.0.100
  [Host]   : .NET Core 3.0.0 (CoreCLR 4.700.19.46205, CoreFX 4.700.19.46214), 64bit RyuJIT
  ShortRun : .NET Core 3.0.0 (CoreCLR 4.700.19.46205, CoreFX 4.700.19.46214), 64bit RyuJIT

Job=ShortRun  InvocationCount=1  IterationCount=3  
LaunchCount=1  UnrollFactor=1  WarmupCount=3  
Method Mean Error StdDev
PutFirstEmptyBlock 4,947.0 us 14,308.1 us 784.27 us
PutFirstBlockWithTxs 26,977.8 us 64,829.5 us 3,553.52 us
PutBlockOnManyBlocks 31,588.7 us 206,062.2 us 11,294.96 us
GetOldBlockOutOfManyBlocks 1,494.3 us 9,766.6 us 535.34 us
GetRecentBlockOutOfManyBlocks 2,370.9 us 11,128.9 us 610.01 us
TryGetNonExistentBlockHash 210.2 us 573.5 us 31.44 us
PutFirstTx 5,980.1 us 10,278.1 us 563.38 us
PutTxOnManyTxs 4,331.6 us 5,927.9 us 324.93 us
GetOldTxOutOfManyTxs 1,727.5 us 7,369.2 us 403.93 us
GetRecentTxOutOfManyTxs 1,564.4 us 19,936.8 us 1,092.81 us
TryGetNonExistentTxId 140.8 us 761.7 us 41.75 us

DefaultStore (Linux)

BenchmarkDotNet=v0.11.5, OS=ubuntu 18.04
Intel Xeon CPU E5-2673 v4 2.30GHz, 1 CPU, 2 logical and 2 physical cores
.NET Core SDK=3.0.100
  [Host]   : .NET Core 3.0.0 (CoreCLR 4.700.19.46205, CoreFX 4.700.19.46214), 64bit RyuJIT
  ShortRun : .NET Core 3.0.0 (CoreCLR 4.700.19.46205, CoreFX 4.700.19.46214), 64bit RyuJIT

Job=ShortRun  InvocationCount=1  IterationCount=3  
LaunchCount=1  UnrollFactor=1  WarmupCount=3  
Method Mean Error StdDev
PutFirstEmptyBlock 567.80 us 1,090.80 us 59.7906 us
PutFirstBlockWithTxs 2,271.70 us 1,489.49 us 81.6442 us
PutBlockOnManyBlocks 1,732.67 us 3,479.72 us 190.7354 us
GetOldBlockOutOfManyBlocks 283.53 us 621.83 us 34.0847 us
GetRecentBlockOutOfManyBlocks 481.47 us 1,962.74 us 107.5845 us
TryGetNonExistentBlockHash 114.87 us 695.88 us 38.1435 us
PutFirstTx 701.24 us 2,942.95 us 161.3127 us
PutTxOnManyTxs 443.07 us 476.14 us 26.0988 us
GetOldTxOutOfManyTxs 25.40 us 44.39 us 2.4334 us
GetRecentTxOutOfManyTxs 22.10 us 15.59 us 0.8544 us
TryGetNonExistentTxId 133.80 us 317.46 us 17.4009 us

LiteDBStore (macOS)

BenchmarkDotNet=v0.11.5, OS=macOS 10.15.1 (19B88) [Darwin 19.0.0]
Intel Xeon CPU E5-1650 v2 3.50GHz (Max: 3.34GHz), 2 CPU, 4 logical and 4 physical cores
.NET Core SDK=3.0.100
  [Host]   : .NET Core 3.0.0 (CoreCLR 4.700.19.46205, CoreFX 4.700.19.46214), 64bit RyuJIT
  ShortRun : .NET Core 3.0.0 (CoreCLR 4.700.19.46205, CoreFX 4.700.19.46214), 64bit RyuJIT

Job=ShortRun  InvocationCount=1  IterationCount=3  
LaunchCount=1  UnrollFactor=1  WarmupCount=3  
Method Mean Error StdDev Median
PutFirstEmptyBlock 11,993.2 us 110,056.5 us 6,032.569 us 8,631.9 us
PutFirstBlockWithTxs 30,739.1 us 38,474.8 us 2,108.935 us 30,326.4 us
PutBlockOnManyBlocks 38,760.6 us 63,501.6 us 3,480.738 us 39,643.5 us
GetOldBlockOutOfManyBlocks 877.0 us 2,232.9 us 122.395 us 940.9 us
GetRecentBlockOutOfManyBlocks 1,669.2 us 657.7 us 36.049 us 1,680.9 us
TryGetNonExistentBlockHash 363.3 us 160.5 us 8.799 us 359.7 us
PutFirstTx 7,117.5 us 7,046.4 us 386.236 us 7,323.9 us
PutTxOnManyTxs 6,499.8 us 9,103.8 us 499.009 us 6,363.6 us
GetOldTxOutOfManyTxs 821.9 us 709.1 us 38.867 us 802.1 us
GetRecentTxOutOfManyTxs 753.3 us 1,345.1 us 73.727 us 795.3 us
TryGetNonExistentTxId 363.6 us 126.5 us 6.937 us 366.6 us

DefaultStore (macOS)

BenchmarkDotNet=v0.11.5, OS=macOS 10.15.1 (19B88) [Darwin 19.0.0]
Intel Xeon CPU E5-1650 v2 3.50GHz (Max: 3.34GHz), 2 CPU, 4 logical and 4 physical cores
.NET Core SDK=3.0.100
  [Host]   : .NET Core 3.0.0 (CoreCLR 4.700.19.46205, CoreFX 4.700.19.46214), 64bit RyuJIT
  ShortRun : .NET Core 3.0.0 (CoreCLR 4.700.19.46205, CoreFX 4.700.19.46214), 64bit RyuJIT

Job=ShortRun  InvocationCount=1  IterationCount=3  
LaunchCount=1  UnrollFactor=1  WarmupCount=3  
Method Mean Error StdDev Median
PutFirstEmptyBlock 1,591.24 us 1,870.6 us 102.536 us 1,639.54 us
PutFirstBlockWithTxs 6,441.34 us 5,953.7 us 326.340 us 6,299.32 us
PutBlockOnManyBlocks 5,282.62 us 3,904.4 us 214.012 us 5,325.88 us
GetOldBlockOutOfManyBlocks 319.00 us 501.2 us 27.474 us 313.77 us
GetRecentBlockOutOfManyBlocks 502.60 us 525.3 us 28.794 us 511.39 us
TryGetNonExistentBlockHash 143.26 us 179.5 us 9.837 us 141.98 us
PutFirstTx 1,552.22 us 1,734.7 us 95.084 us 1,526.22 us
PutTxOnManyTxs 1,438.01 us 6,382.3 us 349.835 us 1,249.71 us
GetOldTxOutOfManyTxs 64.68 us 627.6 us 34.403 us 74.21 us
GetRecentTxOutOfManyTxs 43.98 us 576.6 us 31.607 us 31.30 us
TryGetNonExistentTxId 206.18 us 863.2 us 47.315 us 180.80 us

LiteDBStore (Windows)

BenchmarkDotNet=v0.11.5, OS=Windows 10.0.17763.805 (1809/October2018Update/Redstone5)
Intel Xeon CPU E5-2673 v4 2.30GHz, 1 CPU, 2 logical and 2 physical cores
.NET Core SDK=3.0.100
  [Host]   : .NET Core 3.0.0 (CoreCLR 4.700.19.46205, CoreFX 4.700.19.46214), 64bit RyuJIT
  ShortRun : .NET Core 3.0.0 (CoreCLR 4.700.19.46205, CoreFX 4.700.19.46214), 64bit RyuJIT

Job=ShortRun  InvocationCount=1  IterationCount=3  
LaunchCount=1  UnrollFactor=1  WarmupCount=3  
Method Mean Error StdDev
PutFirstEmptyBlock 34,039.0 us 84,240.2 us 4,617.49 us
PutFirstBlockWithTxs 164,840.5 us 65,459.9 us 3,588.08 us
PutBlockOnManyBlocks 269,539.2 us 284,784.2 us 15,609.98 us
GetOldBlockOutOfManyBlocks 1,366.2 us 1,809.5 us 99.18 us
GetRecentBlockOutOfManyBlocks 2,054.2 us 4,737.0 us 259.65 us
TryGetNonExistentBlockHash 677.3 us 945.5 us 51.82 us
PutFirstTx 42,991.1 us 92,887.2 us 5,091.46 us
PutTxOnManyTxs 55,486.5 us 175,563.6 us 9,623.24 us
GetOldTxOutOfManyTxs 1,047.1 us 3,824.1 us 209.61 us
GetRecentTxOutOfManyTxs 1,248.3 us 6,392.9 us 350.41 us
TryGetNonExistentTxId 756.4 us 815.5 us 44.70 us

DefaultStore (Windows)

BenchmarkDotNet=v0.11.5, OS=Windows 10.0.17763.805 (1809/October2018Update/Redstone5)
Intel Xeon CPU E5-2673 v4 2.30GHz, 1 CPU, 2 logical and 2 physical cores
.NET Core SDK=3.0.100
  [Host]   : .NET Core 3.0.0 (CoreCLR 4.700.19.46205, CoreFX 4.700.19.46214), 64bit RyuJIT
  ShortRun : .NET Core 3.0.0 (CoreCLR 4.700.19.46205, CoreFX 4.700.19.46214), 64bit RyuJIT

Job=ShortRun  InvocationCount=1  IterationCount=3  
LaunchCount=1  UnrollFactor=1  WarmupCount=3  
Method Mean Error StdDev Median
PutFirstEmptyBlock 1,597.33 us 2,410.59 us 132.133 us 1,577.40 us
PutFirstBlockWithTxs 7,476.67 us 4,706.88 us 258.000 us 7,538.40 us
PutBlockOnManyBlocks 6,305.90 us 4,596.80 us 251.966 us 6,309.20 us
GetOldBlockOutOfManyBlocks 303.90 us 1,436.33 us 78.730 us 299.80 us
GetRecentBlockOutOfManyBlocks 459.07 us 982.25 us 53.841 us 487.00 us
TryGetNonExistentBlockHash 90.17 us 274.90 us 15.068 us 94.90 us
PutFirstTx 1,660.03 us 895.54 us 49.088 us 1,643.30 us
PutTxOnManyTxs 1,353.43 us 1,591.14 us 87.216 us 1,320.10 us
GetOldTxOutOfManyTxs 34.80 us 313.26 us 17.171 us 25.80 us
GetRecentTxOutOfManyTxs 24.73 us 78.73 us 4.315 us 22.60 us
TryGetNonExistentTxId 101.03 us 110.35 us 6.048 us 103.20 us

「힘의 차이」가 느껴지십니까?

@dahlia dahlia self-assigned this Nov 11, 2019
@codecov
Copy link

codecov bot commented Nov 11, 2019

Codecov Report

Merging #662 into master will decrease coverage by 0.32%.
The diff coverage is 72.64%.

@@            Coverage Diff            @@
##           master    #662      +/-   ##
=========================================
- Coverage   87.62%   87.3%   -0.33%     
=========================================
  Files         218     218              
  Lines       17714   17760      +46     
=========================================
- Hits        15522   15505      -17     
- Misses       1134    1195      +61     
- Partials     1058    1060       +2
Impacted Files Coverage Δ
Libplanet.Tests/Store/TransactionSetTest.cs 96.49% <100%> (ø) ⬆️
Libplanet.Tests/Store/StoreTrackerTest.cs 100% <100%> (ø) ⬆️
Libplanet.Tests/Blockchain/BlockChainTest.cs 98.63% <100%> (-0.15%) ⬇️
Libplanet.Tests/Store/DefaultStoreTest.cs 96.55% <100%> (ø)
Libplanet.Tests/Net/SwarmTest.cs 98.73% <100%> (-0.11%) ⬇️
...lanet.Tests/Blockchain/Policies/BlockPolicyTest.cs 97.76% <100%> (ø) ⬆️
Libplanet.Tests/Store/BlockSetTest.cs 96.72% <100%> (ø) ⬆️
Libplanet.Tests/Store/StoreExtensionTest.cs 100% <100%> (ø) ⬆️
Libplanet.Tests/Store/StoreTest.cs 96.91% <36.36%> (-2.15%) ⬇️
Libplanet/Store/DefaultStore.cs 82.64% <69.87%> (ø)
... and 7 more

Libplanet/Store/DefaultStore.cs Show resolved Hide resolved
Libplanet/Store/DefaultStore.cs Show resolved Hide resolved
Libplanet/Store/DefaultStore.cs Outdated Show resolved Hide resolved
Libplanet/Store/DefaultStore.cs Outdated Show resolved Hide resolved
CHANGES.md Outdated Show resolved Hide resolved
Libplanet.Tests/Net/SwarmTest.cs Show resolved Hide resolved
Libplanet.Tests/Blockchain/BlockChainTest.cs Show resolved Hide resolved
Libplanet/Store/DefaultStore.cs Outdated Show resolved Hide resolved
Libplanet/Store/DefaultStore.cs Outdated Show resolved Hide resolved
longfin
longfin previously approved these changes Nov 13, 2019
limebell
limebell previously approved these changes Nov 13, 2019
@dahlia dahlia dismissed stale reviews from limebell and longfin via 0047ce4 November 13, 2019 08:16
@dahlia dahlia requested a review from limebell November 13, 2019 08:17
@dahlia dahlia merged commit 7a32b42 into planetarium:master Nov 13, 2019
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