Skip to content

try to pass vm around instead of (heap, interns)#234

Draft
davidhewitt wants to merge 5 commits intomainfrom
dh/pass-vm
Draft

try to pass vm around instead of (heap, interns)#234
davidhewitt wants to merge 5 commits intomainfrom
dh/pass-vm

Conversation

@davidhewitt
Copy link
Collaborator

This WIP attempts to pass vm around more places instead of heap, interns as separate pieces borrowed out of VM. This might help me with problems I'm facing in #207, but it's possible there are other ways to solve it.

I think this refactoring would be necessary if monty ever supports the class statement, as the vm would be needed to run all the user code for magic methods such as __len__ etc.

I think it might also be completely reasonably to not do this and commit to not supporting user-defined classes. I can imagine that user-defined classes are extremely hard to support in the face of suspendable execution, as basically the entire interpreter could suspend at any point, so I think a lot of the code which is currently implemented as Rust would instead have to be rewritten as micro-ops which could be individually suspended. (That might ultimately pay out, but it seems risky / hard / potentially impossible for all code paths, such as when finding hash entry inside a dictionary.)

@codspeed-hq
Copy link

codspeed-hq bot commented Mar 3, 2026

Merging this PR will degrade performance by 13.15%

❌ 1 regressed benchmark
✅ 12 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
fib__monty 157.9 ms 181.8 ms -13.15%

Comparing dh/pass-vm (cfabaa8) with main (353f982)

Open in CodSpeed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant