perf(vm): hoist allowDynamicEnergy out of the opcode loop#6858
Merged
CodeNinjaEvan merged 1 commit intoJun 27, 2026
Merged
Conversation
CodeNinjaEvan
approved these changes
Jun 26, 2026
aiden3885
approved these changes
Jun 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #6857. That PR routed every
VMConfiggetter through a thread-localcurrent()(process-global snapshot + per-constant-call override).VM.playreadsVMConfig.allowDynamicEnergy()once per executed opcode, so after #6857 each opcode now pays aThreadLocal.get()on the block-processing hot path, where before it was a plain, inlinable static read.CPU profiling (release_v4.8.2 vs master, same workload) shows new hot frames on 4.8.2 that are absent on master:
org.tron.core.vm.config.VMConfig.currentjava.lang.ThreadLocal$ThreadLocalMap.getEntryAfterMiss— thelocalSnapshotlookup falls onto the linear-probe miss path on the block thread, which never installs a thread-local view.The flag is VM config: it is loaded once in
VMActuator.validateand is immutable for the whole execution. Reading it once per execution instead of once per opcode is therefore semantically identical and restores the pre-#6857 hot-path cost.vmTrace()is intentionally left untouched — it was not migrated to the snapshot in #6857 and is still a plain static read.Test
:actuator:compileJavagreen.org.tron.common.runtime.vm.OperationsTestgreen (exercises theVM.playloop including dynamic-energy / suicide / vote-witness paths).