Skip to content

Commit

Permalink
Merge pull request #231 from bitcoin-sv/change-batch-size
Browse files Browse the repository at this point in the history
reduce batch size
  • Loading branch information
shotasilagadzetaal authored Jan 4, 2024
2 parents dae364c + 7e2a504 commit 6fbd2d0
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions blocktx/peer_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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()
}
}

Expand Down

0 comments on commit 6fbd2d0

Please sign in to comment.