From 82214f682af4d8dc6753edea21c735ff8d20acf8 Mon Sep 17 00:00:00 2001 From: Laurence Tratt Date: Mon, 23 Mar 2026 22:10:24 +0000 Subject: [PATCH] Only call `load_inst` during tracing. When we're interpreting, `load_inst` and its associated `yk_promote`s are slow. This commit only pays that cost during tracing: this speeds up json by ~4% and a few other benchmarks by a smaller amount (possibly statistically insignificant, but I think there's a small, genuine signal there). --- src/lvm.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/lvm.c b/src/lvm.c index 978c995..e1bd334 100644 --- a/src/lvm.c +++ b/src/lvm.c @@ -1183,9 +1183,13 @@ Instruction load_inst(uint64_t pv, const Instruction *pc) { trap = luaG_traceexec(L, pc); /* handle hooks */ \ updatebase(ci); /* correct stack */ \ } \ - pc = (Instruction *) yk_promote((void *) pc); \ - uint64_t pv = yk_promote(cl_proto_version); \ - i = load_inst(pv, pc); \ + if (yk_is_interpreting()) { \ + i = *pc; \ + } else { \ + pc = (Instruction *) yk_promote((void *) pc); \ + uint64_t pv = yk_promote(cl_proto_version); \ + i = load_inst(pv, pc); \ + } \ pc++; \ } #else