From 3d93587e125bc9eaba74fa0501efd54f3cc9bc3c Mon Sep 17 00:00:00 2001 From: Gabriel Rocheleau Date: Sun, 11 Aug 2024 10:15:44 -0400 Subject: [PATCH] client: vmexecution cache stats refactor --- packages/client/src/execution/vmexecution.ts | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/packages/client/src/execution/vmexecution.ts b/packages/client/src/execution/vmexecution.ts index 07635aa376..2f2ca4d7ad 100644 --- a/packages/client/src/execution/vmexecution.ts +++ b/packages/client/src/execution/vmexecution.ts @@ -40,7 +40,6 @@ import { ReceiptsManager } from './receipt.js' import type { ExecutionOptions } from './execution.js' import type { Block } from '@ethereumjs/block' -import type { Trie } from '@ethereumjs/trie' import type { PrefixedHexString } from '@ethereumjs/util' import type { RunBlockOpts, TxReceipt } from '@ethereumjs/vm' @@ -1066,25 +1065,22 @@ export class VMExecution extends Execution { stats() { if (this._statsVM instanceof DefaultStateManager) { - const sm = this._statsVM.stateManager as any - const disactivatedStats = { size: 0, reads: 0, hits: 0, writes: 0 } + const sm = this._statsVM.stateManager as DefaultStateManager + const deactivatedStats = { size: 0, reads: 0, hits: 0, writes: 0 } let stats - // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions - stats = !sm._accountCacheSettings.deactivate ? sm._accountCache.stats() : disactivatedStats + stats = sm['_caches']?.account?.stats() ?? deactivatedStats this.config.logger.info( `Account cache stats size=${stats.size} reads=${stats.reads} hits=${stats.hits} writes=${stats.writes}`, ) - // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions - stats = !sm._storageCacheSettings.deactivate ? sm._storageCache.stats() : disactivatedStats + stats = sm['_caches']?.storage?.stats() ?? deactivatedStats this.config.logger.info( `Storage cache stats size=${stats.size} reads=${stats.reads} hits=${stats.hits} writes=${stats.writes}`, ) - // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions - stats = !sm._codeCacheSettings.deactivate ? sm._codeCache.stats() : disactivatedStats + stats = sm['_caches']?.code?.stats() ?? deactivatedStats this.config.logger.info( `Code cache stats size=${stats.size} reads=${stats.reads} hits=${stats.hits} writes=${stats.writes}`, ) - const tStats = (sm._trie as Trie).database().stats() + const tStats = sm['_trie'].database().stats() this.config.logger.info( `Trie cache stats size=${tStats.size} reads=${tStats.cache.reads} hits=${tStats.cache.hits} ` + `writes=${tStats.cache.writes} readsDB=${tStats.db.reads} hitsDB=${tStats.db.hits} writesDB=${tStats.db.writes}`,