Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions dataRetriever/dataPool/proofsCache/proofsCache.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,10 @@ func (pc *proofsCache) cleanupProofsInBucket(bucket *proofNonceBucket) {
delete(pc.proofsByHash, headerHash)
}
}

func (pc *proofsCache) getNumProofsByHash() int {
pc.mutProofsCache.RLock()
defer pc.mutProofsCache.RUnlock()

return len(pc.proofsByHash)
}
12 changes: 12 additions & 0 deletions dataRetriever/dataPool/proofsCache/proofsPool.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,18 @@ func (pp *proofsPool) RegisterHandler(handler func(headerProof data.HeaderProofH
pp.mutAddedProofSubscribers.Unlock()
}

func (pp *proofsPool) Len() int {
pp.mutCache.RLock()
defer pp.mutCache.RUnlock()

numProofsByHash := 0
for _, proofsPerShard := range pp.cache {
numProofsByHash += proofsPerShard.getNumProofsByHash()
}

return numProofsByHash
}

// IsInterfaceNil returns true if there is no value under the interface
func (pp *proofsPool) IsInterfaceNil() bool {
return pp == nil
Expand Down
1 change: 1 addition & 0 deletions dataRetriever/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,5 +392,6 @@ type ProofsPool interface {
GetProofByNonce(headerNonce uint64, shardID uint32) (data.HeaderProofHandler, error)
HasProof(shardID uint32, headerHash []byte) bool
IsProofInPoolEqualTo(headerProof data.HeaderProofHandler) bool
Len() int
IsInterfaceNil() bool
}
35 changes: 35 additions & 0 deletions process/block/baseProcess.go
Original file line number Diff line number Diff line change
Expand Up @@ -1312,6 +1312,41 @@ func (bp *baseProcessor) cleanupPools(headerHandler data.HeaderHandler) {
// cleanup all unexecuted transaction from txpool
bp.cleanupUnexecutableTxsFromPool(executionResultHeaderHash)
}

if headerHandler.GetRound()%50 == 0 {
go bp.logPoolsSize()
}
}

func (bp *baseProcessor) logPoolsSize() {
dp := bp.dataPool

log.Debug("logPoolsSize",
"postProcessTxs", "len", dp.PostProcessTransactions().Len(), "size", dp.PostProcessTransactions().SizeInBytesContained(),
"executedMiniBlocksCache", "len", dp.ExecutedMiniBlocks().Len(), "size", dp.ExecutedMiniBlocks().SizeInBytesContained(),
"miniblocks", "len", dp.MiniBlocks().Len(), "size", dp.MiniBlocks().SizeInBytesContained(),
"proofs", "len", dp.Proofs().Len(),
)

log.Debug("logPoolsSize headers",
"headers", "len", dp.Headers().Len(),
)
for i := uint32(0); i < bp.shardCoordinator.NumberOfShards(); i++ {
log.Debug("per shard",
"shardID", i, "numHeaders", dp.Headers().GetNumHeaders(i),
)
}
log.Debug("per shard",
"shardID", core.MetachainShardId, "numHeaders", dp.Headers().GetNumHeaders(core.MetachainShardId),
)

txPoolCounts := dp.Transactions().GetCounts()

log.Debug("logPoolsSize txPool",
"numTrackedBlocks", dp.Transactions().GetNumTrackedBlocks(),
"numTrackedAccounts", dp.Transactions().GetNumTrackedAccounts(),
"id", txPoolCounts.String(), "total", txPoolCounts.GetTotal(), "total size", txPoolCounts.GetTotalSize(),
)
}

func (bp *baseProcessor) cleanupUnexecutableTxsFromPool(headerHash []byte) {
Expand Down
4 changes: 4 additions & 0 deletions testscommon/dataRetriever/proofsPoolMock.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ func (p *ProofsPoolMock) RegisterHandler(handler func(headerProof data.HeaderPro
}
}

func (p *ProofsPoolMock) Len() int {
return 0
}

// IsInterfaceNil -
func (p *ProofsPoolMock) IsInterfaceNil() bool {
return p == nil
Expand Down
Loading