Skip to content

Commit

Permalink
client: vmexecution cache stats refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrocheleau committed Aug 11, 2024
1 parent fdcdb36 commit 3d93587
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions packages/client/src/execution/vmexecution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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}`,
Expand Down

0 comments on commit 3d93587

Please sign in to comment.