Skip to content

Conversation

@Jim8y
Copy link
Contributor

@Jim8y Jim8y commented Oct 16, 2025

Summary

  • cache decoded instructions in an indexed array and tighten strict-mode validation
  • prune evaluation stack/path utilities to avoid extra allocations while matching ref-count semantics
  • add BenchmarkDotNet coverage for VM hot paths to keep perf regression-tracked

Testing

  • dotnet format neo.sln
  • dotnet test neo.sln
  • NEO_VM_BENCHMARK=1 dotnet run -c Release --project benchmarks/Neo.VM.Benchmarks/Neo.VM.Benchmarks.csproj --framework net9.0 --filter Benchmarks_VMHotPaths

Benchmark comparison (mean)

Scenario dev branch Delta
ConstructStrictScript (32) 1.36 µs 0.79 µs -42%
ConstructStrictScript (256) 8.43 µs 5.70 µs -32%
ConstructStrictScript (1024) 31.9 µs 22.8 µs -29%
IterateInstructions (32) 198 ns 59.6 ns 3.3×
IterateInstructions (256) 1.75 µs 0.684 µs 2.6×
IterateInstructions (1024) 6.97 µs 2.74 µs 2.5×
ExecutePushAndReturn (32) 57.1 µs 55.7 µs -2.5%
ExecutePushAndReturn (256) 61.7 µs 63.2 µs +2.4% (variance)
ExecutePushAndReturn (1024) 81.6 µs 81.7 µs ~0%

@Jim8y Jim8y marked this pull request as draft October 16, 2025 23:11
Comment on lines +51 to +60
var length = end - start;
if (length == 0)
return System.Array.Empty<StackItem>();

return reverseList.GetRange(start, end - start);
StackItem[] result = new StackItem[length];
var sourceIndex = _innerList.Count - start - 1;
for (int i = 0; i < length; i++)
result[i] = _innerList[sourceIndex - i];

return result;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change this back there is a good reason why I wrote it the way I did. Can you explain your reasoning why you changed it? This way uses a loop. So, having big lists of data, you'll see performance issues come up. You guys tried to change it this way before.

We talked about it in a meeting about why its written this way from #4050

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a draft, do not review

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just saying it so your aware of what your doing. I want you to succeed.

Comment on lines 89 to 90
for (int i = 0; i < _innerList.Count; i++)
stack._innerList.Add(_innerList[i]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These loops are so inefficient.

@Wi1l-B0t
Copy link
Contributor

Wi1l-B0t commented Oct 17, 2025

Why are all the PRs you submitted marked as WIP/Draft?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants