From d2682c9e64009bfaa7085495f99e2dc71d45363e Mon Sep 17 00:00:00 2001 From: ssilagadze Date: Thu, 4 Jan 2024 14:20:53 +0400 Subject: [PATCH 1/2] reduce batch size --- blocktx/peer_handler.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blocktx/peer_handler.go b/blocktx/peer_handler.go index 073c9b860..a87ae8de4 100644 --- a/blocktx/peer_handler.go +++ b/blocktx/peer_handler.go @@ -27,7 +27,7 @@ import ( ) const ( - transactionStoringBatchsizeDefault = 65536 // power of 2 for easier memory allocation + transactionStoringBatchsizeDefault = 2048 // power of 2 for easier memory allocation maxRequestBlocks = 5 ) From 7e2a504cde0e39968b560fcbef48a4f97f675ae1 Mon Sep 17 00:00:00 2001 From: ssilagadze Date: Thu, 4 Jan 2024 15:20:25 +0400 Subject: [PATCH 2/2] log memory stats --- blocktx/peer_handler.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/blocktx/peer_handler.go b/blocktx/peer_handler.go index a87ae8de4..e3a912527 100644 --- a/blocktx/peer_handler.go +++ b/blocktx/peer_handler.go @@ -447,14 +447,15 @@ func (bs *PeerHandler) insertBlock(blockHash *chainhash.Hash, merkleRoot *chainh return bs.store.InsertBlock(context.Background(), block) } -func printMemStats() { +func (bs *PeerHandler) printMemStats() { bToMb := func(b uint64) uint64 { return b / 1024 / 1024 } var mem runtime.MemStats runtime.ReadMemStats(&mem) - fmt.Printf("Alloc = %v MiB, TotalAlloc = %v MiB, Sys = %v MiB, NumGC = %v\n", - bToMb(mem.Alloc), bToMb(mem.TotalAlloc), bToMb(mem.Sys), mem.NumGC) + bs.logger.Info(fmt.Sprintf("Alloc = %v MiB, TotalAlloc = %v MiB, Sys = %v MiB, NumGC = %v\n", + bToMb(mem.Alloc), bToMb(mem.TotalAlloc), bToMb(mem.Sys), mem.NumGC)) + } func (bs *PeerHandler) markTransactionsAsMined(blockId uint64, merkleTree []*chainhash.Hash, blockHeight uint64) error { @@ -498,9 +499,9 @@ func (bs *PeerHandler) markTransactionsAsMined(blockId uint64, merkleTree []*cha merklePaths = merklePaths[:0] // print stats, call gc and chec the result - printMemStats() + bs.printMemStats() runtime.GC() - printMemStats() + bs.printMemStats() } }