Skip to content

refactor: Clean up DSL#270

Open
mhovd wants to merge 5 commits into
mainfrom
dsl-cleanup
Open

refactor: Clean up DSL#270
mhovd wants to merge 5 commits into
mainfrom
dsl-cleanup

Conversation

@mhovd

@mhovd mhovd commented Jun 2, 2026

Copy link
Copy Markdown
Collaborator

This PR consolidates duplicated per-role kernel boilerplate across the four DSL backends (JIT, AoT, WASM, native) and dedupes a few small helpers in the DSL frontend. Behavior is unchanged; signatures on internal constructors were tightened.

The four backends each carried near-identical 8-way fan-outs over KernelRole — one per kernel field, one per role symbol, one per match arm. That made adding or renaming a role a multi-file, multi-block edit and obscured the actual per-backend logic (Cranelift module ownership in JIT, libloading symbol resolution in AoT, wasmtime typed-func lookup in WASM). Grouping the per-role state into one struct and routing role lookups through a single helper makes the per-role surface explicit and shrinks each backend to the part that's actually backend-specific.

No public API changes outside the DSL backend modules. Constructor signature changes (from_jit_module, from_library, WasmKernelSession::new) are internal to src/dsl.

Written by Claude Opus 4.7, verified by myself.

Copilot AI review requested due to automatic review settings June 2, 2026 13:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR consolidates duplicated per-KernelRole fan-outs across the four DSL backends (JIT, AoT, WASM, native) by introducing a shared NativeKernels table on NativeExecutionArtifact, reusing CompiledKernelAvailability in the WASM backend, and routing role lookups through helper functions. It also dedupes two small numeric-label helpers in the DSL frontend by moving them into name_match. The behavior is intended to be unchanged; only internal constructor signatures (from_jit_module, from_library, WasmKernelSession::new) are tightened.

Changes:

  • Introduce NativeKernels (with get/has/Debug) and re-route NativeExecutionArtifact and its KernelSession/RuntimeArtifact impls through it; update JIT/AoT call sites to construct it.
  • Replace WasmKernelAvailability with the existing CompiledKernelAvailability, factor a maybe_typed_func helper, and promote kernel_output_len to a shared pub(super) helper in compiled_backend_abi.
  • Move bare_numeric_label/canonical_numeric_suffix from authoring.rs and semantic.rs into name_match.rs and import them from there.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/dsl/native.rs Extract per-role kernel fields into a new NativeKernels struct with get/has/Debug impls; route KernelSession::invoke_raw and has_kernel through it.
src/dsl/jit.rs Compile kernels into a fixed-size [Option<FuncId>; 8] indexed by role_index, then build a NativeKernels for the artifact; update tests to access artifact.kernels.*.
src/dsl/aot.rs Build a NativeKernels literal and pass it into from_library instead of eight positional arguments.
src/dsl/wasm.rs Drop WasmKernelAvailability in favor of CompiledKernelAvailability; add maybe_typed_func helper; remove local kernel_output_len and import the shared one.
src/dsl/compiled_backend_abi.rs Promote kernel_output_len from #[cfg(test)] to pub(super) for cross-module reuse.
pharmsol-dsl/src/name_match.rs Add bare_numeric_label and canonical_numeric_suffix as pub(crate) helpers.
pharmsol-dsl/src/semantic.rs Remove local copies of the numeric-label helpers and import them from name_match.
pharmsol-dsl/src/authoring.rs Same dedup as semantic.rs: import from name_match instead of redefining.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/dsl/native.rs
Comment on lines 117 to 125
@@ -119,6 +123,49 @@ pub struct NativeExecutionArtifact {
pub diffusion: Option<DenseKernelFn>,
pub route_lag: Option<DenseKernelFn>,
pub route_bioavailability: Option<DenseKernelFn>,
@github-actions

github-actions Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchdsl-cleanup
Testbedmhovd-pgx

⚠️ WARNING: Truncated view!

The full continuous benchmarking report exceeds the maximum length allowed on this platform.

🐰 View full continuous benchmarking report in Bencher

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