Skip to content

Let generated interpreters handle 'nothing' values. - #50

Open
StefRasing wants to merge 10 commits into
masterfrom
exception_free_interpreter
Open

Let generated interpreters handle 'nothing' values.#50
StefRasing wants to merge 10 commits into
masterfrom
exception_free_interpreter

Conversation

@StefRasing

Copy link
Copy Markdown

Exception throwing and catching in Julia is really really slow. A better way to handle invalid arguments or parsing is to let domain functions return a special value in stead of throwing exceptions. I choose nothing as an exception, but we might use more informative exceptions.

To correctly pass exceptions upstream, the interpreter needs to return nothing if any child of the interpreted program produces nothing.

To give a sense of the speed-up this might give; a certain SyGuS string problem was solved in ±12s using the old interpreter, but with this fix it only took ±1s. This is a huge speedup, but the string domain is exception heavy. I don't think fix will harm performance in any other way.

@codecov

codecov Bot commented Mar 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.59322% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.67%. Comparing base (b5a6c5c) to head (1eeaf88).

Files with missing lines Patch % Lines
src/make_interpret.jl 85.59% 17 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #50      +/-   ##
==========================================
+ Coverage   69.11%   76.67%   +7.56%     
==========================================
  Files           3        3              
  Lines         204      283      +79     
==========================================
+ Hits          141      217      +76     
- Misses         63       66       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

github-actions Bot commented Mar 24, 2026

Copy link
Copy Markdown

Benchmark Results

master 1eeaf88... master / 1eeaf88...
interpret/Random Expressions 0.124 ± 0.0017 ms 0.125 ± 0.0016 ms 0.989 ± 0.019
time_to_load 0.0827 ± 0.00086 s 0.0832 ± 0.00042 s 0.995 ± 0.011

Benchmark Plots

A plot of the benchmark results have been uploaded as an artifact to the workflow run for this PR.
Go to "Actions"->"Benchmark a pull request"->[the most recent run]->"Artifacts" (at the bottom).

@THinnerichs

THinnerichs commented Mar 26, 2026

Copy link
Copy Markdown
Member

Thoughts:

  1. I think moving to eager evaluation from lazy evaluation should not have an impact.
  2. You use nothing to denote "An exception should have been thrown here". We should use a dedicated struct for this and wrap the result so we can dispatch over it:
module HerbInterpret
...

struct InterpretException <: Expception end

struct InterpretResult{R} ... end 
...
end
  1. Note to myself:
  • Update stateful formulation, too
  • Double check whether this changes the interpretation of composites; understand why it doesn't.

…s in stateful grammars; added tests; updated docstrings for core functions
@ReubenJ

ReubenJ commented Mar 26, 2026

Copy link
Copy Markdown
Member

https://github.com/Herb-AI/HerbInterpret.jl/tree/bench/update-to-generated now includes examples of using the generated interpreters in the ./benchmark/benchmark.jl setup — just in case that's useful.

THinnerichs and others added 5 commits April 1, 2026 11:23
This interpreter works on a rule_id and list of children outputs instead of an entire program. This way a user can interpret cached results.
@ReubenJ

ReubenJ commented Apr 28, 2026

Copy link
Copy Markdown
Member

Is this ready for review?

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.

3 participants