@@ -16,7 +16,7 @@ import scala.util.{Random, Try}
1616trait BenchmarkCommons {
1717 val hf = new Blake2b256Unsafe ()
1818
19- val initElements = 5000000
19+ val initialSize = 5000000
2020
2121 val blocks = 90000
2222
@@ -33,11 +33,6 @@ trait TwoPartyCommons extends BenchmarkCommons with UpdateF[TreapValue] {
3333 cacheSize(1 ).
3434 open()
3535
36- /* DBMaker
37- .fileDB("/tmp/proofs")
38- .closeOnJvmShutdown()
39- .make()*/
40-
4136 lazy val proofsMap = db.openMap[Integer , Array [Byte ]](" proofs" )
4237
4338 def set (value : TreapValue ): UpdateFunction = { oldOpt : Option [TreapValue ] => Try (Some (oldOpt.getOrElse(value))) }
@@ -62,8 +57,8 @@ trait Initializing extends BenchmarkCommons {
6257 protected var keyCache : mutable.Buffer [hf.Digest ] = mutable.Buffer ()
6358
6459 def init (): Unit = {
65- (0 until initElements - keyCacheSize).foreach(initStep)
66- keyCache.appendAll(((initElements - keyCacheSize) until initElements ).map(initStep))
60+ (0 until initialSize - keyCacheSize).foreach(initStep)
61+ keyCache.appendAll(((initialSize - keyCacheSize) until initialSize ).map(initStep))
6762 afterInit()
6863 }
6964}
@@ -79,7 +74,6 @@ class Prover extends TwoPartyCommons with Initializing {
7974 }
8075
8176 override protected def afterInit (): Unit = {
82- // val rootVar = db.atomicVar("root", Serializer.BYTE_ARRAY).createOrOpen()
8377 setRoot(treeRoot)
8478 db.commit()
8579 }
@@ -102,7 +96,7 @@ class Prover extends TwoPartyCommons with Initializing {
10296
10397 // proofs generation
10498 def dumpProofs (blockNum : Int , proofs : Seq [AVLModifyProof ]): Unit = {
105- var idx = initElements + perBlock * blockNum
99+ var idx = initialSize + perBlock * blockNum
106100 proofs.foreach { proof =>
107101 proofsMap.put(idx, proof.bytes)
108102 idx = idx + 1
@@ -174,7 +168,7 @@ class Verifier extends TwoPartyCommons {
174168 lazy val initRoot = getRoot()
175169
176170 def loadProofs (blockNum : Int ): Seq [AVLModifyProof ] = {
177- (initElements + perBlock * blockNum) until (initElements + perBlock * (blockNum + 1 )) map { idx =>
171+ (initialSize + perBlock * blockNum) until (initialSize + perBlock * (blockNum + 1 )) map { idx =>
178172 AVLModifyProof .parseBytes(proofsMap.get(idx)).get
179173 }
180174 }
@@ -301,12 +295,18 @@ trait BenchmarkLaunchers extends BenchmarkCommons {
301295 val sf = System .currentTimeMillis()
302296 val dsf = sf - sf0
303297 p.dumpProofs(blockNum, proofs, root, modKeys)
304- println(s " block # $blockNum, prover: $dsf" )
305-
298+ println(s " block # $blockNum, " +
299+ s " prover time: $dsf, " +
300+ s " state size before: ${initialSize + (blockNum - 1 )* additionsInBlock}, " +
301+ s " state size after: ${initialSize + blockNum * additionsInBlock} " +
302+ s " proofs size: ${proofs.size}"
303+ )
304+
305+ /* todo: is regular GC needed?
306306 if (blockNum % 5000 == 4999) {
307307 System.gc()
308308 Thread.sleep(60000)
309- }
309+ }*/
310310 }
311311 p.close()
312312 }
0 commit comments