Skip to content

Move header-only C++ runtime to dedicated runtime library - #103

Draft
Pennnnnnnny wants to merge 18 commits into
Generative-Program-Analysis:mainfrom
Pennnnnnnny:genwasym-runtime-setup
Draft

Pennnnnnnny wants to merge 18 commits into
Generative-Program-Analysis:mainfrom
Pennnnnnnny:genwasym-runtime-setup

Conversation

@Pennnnnnnny

Copy link
Copy Markdown

This PR adds the initial genwasym_runtime structure and includes some current runtime-related changes.
Main changes:

  • Added genwasym_runtime directory structure.
  • Added runtime include files.
  • Added initial Makefile/runtime setup.

@butterunderflow
butterunderflow marked this pull request as draft May 13, 2026 17:40
@butterunderflow butterunderflow changed the title Add initial GenWasm runtime structure Move header-only C++ runtime to dedicated runtime library May 13, 2026
@Pennnnnnnny
Pennnnnnnny force-pushed the genwasym-runtime-setup branch from b23daa3 to adf7bd5 Compare September 9, 2026 14:49
@Pennnnnnnny

Copy link
Copy Markdown
Author

Compilation-time benchmark

I tested the generated C++ compilation time before and after the pre-built GenWasm runtime refactor.

The benchmark compares:

  • Before: header-only runtime
  • After: pre-built libgenwasym

For each test case, I measured the direct clang++ compile/link time of the generated C++ code. Each value is the average of 3 runs on the same machine. The benchmark does not include sbt, C++ generation time, generated executable runtime, or the one-time runtime library build time.

I tested both -O0 and -O3.

-O0

Test case Header-only lib Pre-built lib
small-snapshot-concrete 7.23 s 5.793 s
large-branch-concrete 2.91 s 1.493 s
fib - concrete 2.66 s 1.373 s
fact - concrete 2.63 s 1.337 s
ack-cpp - concrete 2.92 s 1.363 s

-O3

Test case Header-only lib Pre-built lib
small-snapshot-concrete 385.923 s 100.777 s
large-branch-concrete 6.200 s 4.727 s
fib - concrete 5.863 s 2.963 s
fact - concrete 5.263 s 2.883 s
ack-cpp - concrete 5.327 s 2.937 s

Across the controlled test cases, I did not observe a compilation-time regression after moving the runtime to the pre-built library. The pre-built runtime reduced generated C++ compile/link time in all tested cases, with the largest improvement appearing for the large small-snapshot-concrete workload under -O3.

Note: fact - concrete generated different C++ between the header-only and pre-built versions, so its timing is included for completeness.

I attached the benchmark script below so the same comparison can be reproduced:
benchmark_genwasym_compile.sh

@Kraks

Kraks commented Sep 14, 2026

Copy link
Copy Markdown
Member

Thanks @Pennnnnnnny and @butterunderflow! This looks like a good improvement in compilation time, can you also list the size of these C++ files as well as the number of C++ files? Another thing I noticed is that the headers still include some immer/* headers, is it necessary? I think we should be able to move all immer-related code into the runtime lib, and I guess that would further improve compilation time.

@Kraks

Kraks commented Sep 14, 2026

Copy link
Copy Markdown
Member

It would be good to also separate interfaces for the generated code, and interfaces for the runtime itself, so that we can minimize the header exposed to the generated code. For example, in GenSym, the former is quite a compact header file https://github.com/Generative-Program-Analysis/GenSym/blob/main/headers/gensym/runtime.hpp, which doesn't rely on immer, and the header for the runtime is https://github.com/Generative-Program-Analysis/GenSym/blob/main/headers/gensym.hpp, which includes everything that used to be in the monolithic header.

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