Skip to content

Commit

Permalink
Warpy benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
asiaziola committed Aug 10, 2024
1 parent 024ed9b commit 49af3e0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/core/modules/impl/CacheableStateEvaluator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { DefaultStateEvaluator } from './DefaultStateEvaluator';
import { HandlerApi } from './HandlerExecutorFactory';
import { genesisSortKey } from './LexicographicalInteractionsSorter';
import { BasicSortKeyCache } from '../../../cache/BasicSortKeyCache';
import { Benchmark } from 'logging/Benchmark';

/**
* An implementation of DefaultStateEvaluator that adds caching capabilities.
Expand Down Expand Up @@ -98,7 +99,10 @@ export class CacheableStateEvaluator extends DefaultStateEvaluator {
}]`
);

const putInCacheBenchmark = Benchmark.measure();
await this.putInCache(contractTxId, transaction, state);
putInCacheBenchmark.stop();
this.cLogger.info('Benchmark put in cache', putInCacheBenchmark.elapsed());
}

async onStateUpdate<State>(
Expand Down
9 changes: 9 additions & 0 deletions src/core/modules/impl/DefaultStateEvaluator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export abstract class DefaultStateEvaluator implements StateEvaluator {
baseState: EvalStateResult<State>,
executionContext: ExecutionContext<State, HandlerApi<State>>
): Promise<SortKeyCacheResult<EvalStateResult<State>>> {
const wholeReadStateBenchmark = Benchmark.measure();
const { ignoreExceptions, stackTrace, internalWrites } = executionContext.evaluationOptions;
const { contract, contractDefinition, sortedInteractions, warp, signal } = executionContext;

Expand All @@ -63,7 +64,10 @@ export abstract class DefaultStateEvaluator implements StateEvaluator {
const errorMessages = baseState.errorMessages;

// TODO: opt - reuse wasm handlers
const initStateBenchmark = Benchmark.measure();
executionContext?.handler.initState(currentState);
initStateBenchmark.stop();
this.logger.info('Benchmark init state', initStateBenchmark.elapsed());
const depth = executionContext.contract.callDepth();

this.logger.debug(
Expand Down Expand Up @@ -242,11 +246,14 @@ export abstract class DefaultStateEvaluator implements StateEvaluator {

const interactionCall: InteractionCall = contract.getCallStack().addInteractionData(interactionData);

const resultBenchmark = Benchmark.measure();
const result = await executionContext.handler.handle(
executionContext,
new EvalStateResult(currentState, validity, errorMessages),
interactionData
);
resultBenchmark.stop();
this.logger.info('Result benchmark', resultBenchmark.elapsed());

errorMessage = result.errorMessage;
if (result.type !== 'ok') {
Expand Down Expand Up @@ -348,6 +355,8 @@ export abstract class DefaultStateEvaluator implements StateEvaluator {
await this.onStateEvaluated(lastConfirmedTxState.tx, executionContext, lastConfirmedTxState.state);
}

wholeReadStateBenchmark.stop();
this.logger.info('Benchmark whole read', wholeReadStateBenchmark.elapsed());
return new SortKeyCacheResult(currentSortKey, evalStateResult);
}

Expand Down

0 comments on commit 49af3e0

Please sign in to comment.