lower addrContractsCacheAlwaysSize to 100 000

This commit is contained in:
pragmaxim
2026-02-06 19:57:26 +01:00
parent 7013f85ac7
commit 57bcb32471
3 changed files with 12 additions and 8 deletions

View File

@@ -1,6 +1,7 @@
package db
import (
"sync/atomic"
"time"
"github.com/golang/glog"
@@ -250,7 +251,8 @@ func (b *BulkConnect) connectBlockBitcoinType(block *bchain.Block, storeBlockTxs
return err
}
if bac > b.bulkAddressesCount {
glog.Info("rocksdb: height ", b.height, ", stored ", bac, " addresses, done in ", time.Since(start))
oversizeSkipped := atomic.SwapUint64(&b.d.addrContractsCacheState.oversizeSkipped, 0)
glog.Info("rocksdb: height ", b.height, ", stored ", bac, " addresses, oversize_skipped=", oversizeSkipped, ", done in ", time.Since(start))
}
}
if storeAddressesChan != nil {
@@ -358,7 +360,8 @@ func (b *BulkConnect) connectBlockEthereumType(block *bchain.Block, storeBlockTx
return err
}
if bac > b.bulkAddressesCount {
glog.Info("rocksdb: height ", b.height, ", stored ", bac, " addresses, done in ", time.Since(start))
oversizeSkipped := atomic.SwapUint64(&b.d.addrContractsCacheState.oversizeSkipped, 0)
glog.Info("rocksdb: height ", b.height, ", stored ", bac, " addresses, oversize_skipped=", oversizeSkipped, ", done in ", time.Since(start))
}
} else {
// if there are blockSpecificData, store them
@@ -425,7 +428,8 @@ func (b *BulkConnect) Close() error {
if err := b.d.WriteBatch(wb); err != nil {
return err
}
glog.Info("rocksdb: height ", b.height, ", stored ", bac, " addresses, done in ", time.Since(start))
oversizeSkipped := atomic.SwapUint64(&b.d.addrContractsCacheState.oversizeSkipped, 0)
glog.Info("rocksdb: height ", b.height, ", stored ", bac, " addresses, oversize_skipped=", oversizeSkipped, ", done in ", time.Since(start))
if storeTxAddressesChan != nil {
if err := <-storeTxAddressesChan; err != nil {
return err

View File

@@ -57,8 +57,8 @@ const (
addressBalanceDetailUTXOIndexed = 2
)
const addrContractsCacheMinSize = 300_000 // limit for caching address contracts in memory to speed up indexing
const addrContractsCacheAlwaysSize = 300_000
const addrContractsCacheMinSize = 100_000 // limit for caching address contracts in memory to speed up indexing
const addrContractsSkipSize = 100_000
const addrContractsCacheHotMinScore = 2.0
const addrContractsHotHalfLife = 45 * time.Minute
const addrContractsHotEvictAfter = 8 * time.Hour
@@ -179,7 +179,7 @@ func NewRocksDB(path string, cacheSize, maxOpenFiles int, parser bchain.BlockCha
hot: make(map[string]*addrContractsHotEntry),
hotSeen: make(map[string]struct{}),
minSizeBytes: addrContractsCacheMinSize,
alwaysSizeBytes: addrContractsCacheAlwaysSize,
alwaysSizeBytes: addrContractsSkipSize,
hotMinScore: addrContractsCacheHotMinScore,
hotHalfLife: addrContractsHotHalfLife,
hotEvictAfter: addrContractsHotEvictAfter,

View File

@@ -11,10 +11,10 @@ Some behavior of Blockbook can be modified by environment variables. The variabl
- `<coin shortcut>_ALLOWED_RPC_CALL_TO` - Addresses to which `rpcCall` websocket requests can be made, as a comma-separated list. If omitted, `rpcCall` is enabled for all addresses.
- `<coin shortcut>_ADDR_CONTRACTS_CACHE_MIN_SIZE`
Default: `300000`
Default: `100000`
Description: Minimum packed size (bytes) to consider addressContracts hotness/caching. Accepts bytes or `K/M/G/T` suffixes (e.g. `300000`, `300K`, `1MiB`).
- `<coin shortcut>_ADDR_CONTRACTS_CACHE_ALWAYS_SIZE`
Default: `300000`
Default: `100000`
Description: Always cache addressContracts above this packed size (bytes). Accepts bytes or `K/M/G/T` suffixes.
- `<coin shortcut>_ADDR_CONTRACTS_CACHE_HOT_MIN_SCORE`
Default: `2`