Skip to content

Commit 8b2b33a

Browse files
committed
tmp pools logs
1 parent d4a8c79 commit 8b2b33a

5 files changed

Lines changed: 48 additions & 0 deletions

File tree

dataRetriever/dataPool/proofsCache/proofsCache.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,10 @@ func (pc *proofsCache) cleanupProofsInBucket(bucket *proofNonceBucket) {
108108
delete(pc.proofsByHash, headerHash)
109109
}
110110
}
111+
112+
func (pc *proofsCache) getNumProofsByHash() int {
113+
pc.mutProofsCache.RLock()
114+
defer pc.mutProofsCache.RUnlock()
115+
116+
return len(pc.proofsByHash)
117+
}

dataRetriever/dataPool/proofsCache/proofsPool.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,18 @@ func (pp *proofsPool) RegisterHandler(handler func(headerProof data.HeaderProofH
224224
pp.mutAddedProofSubscribers.Unlock()
225225
}
226226

227+
func (pp *proofsPool) Len() int {
228+
pp.mutCache.RLock()
229+
defer pp.mutCache.RUnlock()
230+
231+
numProofsByHash := 0
232+
for _, proofsPerShard := range pp.cache {
233+
numProofsByHash += proofsPerShard.getNumProofsByHash()
234+
}
235+
236+
return numProofsByHash
237+
}
238+
227239
// IsInterfaceNil returns true if there is no value under the interface
228240
func (pp *proofsPool) IsInterfaceNil() bool {
229241
return pp == nil

dataRetriever/interface.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,5 +386,6 @@ type ProofsPool interface {
386386
GetProofByNonce(headerNonce uint64, shardID uint32) (data.HeaderProofHandler, error)
387387
HasProof(shardID uint32, headerHash []byte) bool
388388
IsProofInPoolEqualTo(headerProof data.HeaderProofHandler) bool
389+
Len() int
389390
IsInterfaceNil() bool
390391
}

process/block/baseProcess.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1246,6 +1246,30 @@ func (bp *baseProcessor) cleanupPools(headerHandler data.HeaderHandler) {
12461246
// cleanup all log events
12471247
bp.dataPool.PostProcessTransactions().Remove(common.PrepareLogEventsKey(executionResultHeaderHash))
12481248
}
1249+
1250+
if headerHandler.GetRound()%50 == 0 {
1251+
go bp.logPoolsSize()
1252+
}
1253+
}
1254+
1255+
func (bp *baseProcessor) logPoolsSize() {
1256+
dp := bp.dataPool
1257+
1258+
log.Debug("logPoolsSize",
1259+
"postProcessTxs", "len", dp.PostProcessTransactions().Len(), "size", dp.PostProcessTransactions().SizeInBytesContained(),
1260+
"executedMiniBlocksCache", "len", dp.ExecutedMiniBlocks().Len(), "size", dp.ExecutedMiniBlocks().SizeInBytesContained(),
1261+
"miniblocks", "len", dp.MiniBlocks().Len(), "size", dp.MiniBlocks().SizeInBytesContained(),
1262+
"headers", "len", dp.MiniBlocks().Len(),
1263+
"proofs", "len", dp.Proofs().Len(),
1264+
)
1265+
1266+
txPoolCounts := dp.Transactions().GetCounts()
1267+
1268+
log.Debug("logPoolsSize txPool",
1269+
"numTrackedBlocks", dp.Transactions().GetNumTrackedBlocks(),
1270+
"numTrackedAccounts", dp.Transactions().GetNumTrackedAccounts(),
1271+
"counts", "id", txPoolCounts.String(), "total", txPoolCounts.GetTotal(), "total size", txPoolCounts.GetTotalSize(),
1272+
)
12491273
}
12501274

12511275
func (bp *baseProcessor) cleanupPoolsForCrossShard(

testscommon/dataRetriever/proofsPoolMock.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ func (p *ProofsPoolMock) RegisterHandler(handler func(headerProof data.HeaderPro
8787
}
8888
}
8989

90+
func (p *ProofsPoolMock) Len() int {
91+
return 0
92+
}
93+
9094
// IsInterfaceNil -
9195
func (p *ProofsPoolMock) IsInterfaceNil() bool {
9296
return p == nil

0 commit comments

Comments
 (0)