log timing of applying additions and removals to the coin store (#8493)

This commit is contained in:
Arvid Norberg 2021-09-17 19:41:23 +02:00 committed by GitHub
parent 55baeb532a
commit b66db03528
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -8,6 +8,10 @@ from chia.types.coin_record import CoinRecord
from chia.util.db_wrapper import DBWrapper
from chia.util.ints import uint32, uint64
from chia.util.lru_cache import LRUCache
from time import time
import logging
log = logging.getLogger(__name__)
class CoinStore:
@ -72,6 +76,8 @@ class CoinStore:
Only called for blocks which are blocks (and thus have rewards and transactions)
"""
start = time()
for coin in tx_additions:
record: CoinRecord = CoinRecord(
coin,
@ -105,6 +111,13 @@ class CoinStore:
# Sanity check, already checked in block_body_validation
assert sum([a.amount for a in tx_additions]) <= total_amount_spent
end = time()
if end - start > 10:
log.warning(
f"It took {end - start:0.2}s to apply {len(tx_additions)} additions and "
+ f"{len(tx_removals)} removals to the coin store. Make sure "
+ "blockchain database is on a fast drive"
)
# Checks DB and DiffStores for CoinRecord with coin_name and returns it
async def get_coin_record(self, coin_name: bytes32) -> Optional[CoinRecord]: