Skip to content

Commit

Permalink
some more stats
Browse files Browse the repository at this point in the history
  • Loading branch information
yamt committed May 10, 2023
1 parent d58f4f7 commit 2c31a7c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ struct exec_stat {
uint64_t type_annotation_lookup1;
uint64_t type_annotation_lookup2;
uint64_t type_annotation_lookup3;
uint64_t interrupt_exit;
uint64_t interrupt_suspend;
uint64_t interrupt_usched;
uint64_t interrupt_debug;
uint64_t exec_loop_restart;
uint64_t call_restart;
uint64_t tail_call_restart;
Expand Down
8 changes: 8 additions & 0 deletions lib/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -894,20 +894,23 @@ check_interrupt(struct exec_context *ctx)
*/
if (ctx->intrp != NULL && *ctx->intrp != 0) {
xlog_trace("get interrupt");
STAT_INC(ctx->stats.interrupt_exit);
return trap_with_id(ctx, TRAP_VOLUNTARY_THREAD_EXIT,
"interrupt");
}
#if defined(TOYWASM_ENABLE_WASM_THREADS)
if (ctx->cluster != NULL) {
int ret = suspend_check_interrupt(ctx->cluster);
if (ret != 0) {
STAT_INC(ctx->stats.interrupt_suspend);
return ret;
}
}
#endif /* defined(TOYWASM_ENABLE_WASM_THREADS) */
#if defined(TOYWASM_USE_USER_SCHED)
if (ctx->sched != NULL && sched_need_resched(ctx->sched)) {
xlog_trace("%s: need resched ctx %p", __func__, (void *)ctx);
STAT_INC(ctx->stats.interrupt_usched);
return ETOYWASMRESTART;
}
#else /* defined(TOYWASM_USE_USER_SCHED) */
Expand All @@ -924,6 +927,7 @@ check_interrupt(struct exec_context *ctx)
static int x = 0;
x++;
if ((x % 10) == 0) {
STAT_INC(ctx->stats.interrupt_debug);
return ETOYWASMRESTART;
}
#endif
Expand Down Expand Up @@ -1304,6 +1308,10 @@ exec_context_print_stats(struct exec_context *ctx)
STAT_PRINT(type_annotation_lookup1);
STAT_PRINT(type_annotation_lookup2);
STAT_PRINT(type_annotation_lookup3);
STAT_PRINT(interrupt_exit);
STAT_PRINT(interrupt_suspend);
STAT_PRINT(interrupt_usched);
STAT_PRINT(interrupt_debug);
STAT_PRINT(exec_loop_restart);
STAT_PRINT(call_restart);
STAT_PRINT(tail_call_restart);
Expand Down

0 comments on commit 2c31a7c

Please sign in to comment.