Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Faster interpreter #1225

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from
Draft

Faster interpreter #1225

wants to merge 14 commits into from

Conversation

tjhance
Copy link
Collaborator

@tjhance tjhance commented Jul 14, 2024

This is a proof-of-concept for a faster interpreter. It needs a lot of work to reach feature parity with the current one, but it is orders of magnitude faster. As a test case I have been using the bin-sizes lemma from the mem allocator project, which loops over 100k values. We previously found this example to be infeasible, taking several minutes at the very least. With the faster interpreter in this PR, it completes in a couple of seconds.

This new interpreter works by "compiling" spec expressions into a simple stack-based instruction set with instructions for unary ops, binary ops, jumps, constructors, calls, memoized calls, and closure calls. We also operate on a new datatype, called Value, rather than working with Exp. Though not implemented yet, the plan is to convert Values back to Exps for the 'compute-followed-by-z3' mode. The logic for all the different unary ops and binary ops is mostly unchanged, just copied and adjusted for the new datatypes.

Some advantages of this system:

  • execution doesn't have to work with identifiers at all, reducing the need for hash lookups
  • fewer allocations because we aren't working with Exps or Typs
  • execution is driven by a loop { } rather than recursion, thus reducing the stack overflow issues that require the current interpreter to launch a new thread
  • this is basically how computers work so it seemed reasonable to me that it'd be pretty fast

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