feat: add prefigure-rust as an opt-in evaluation backend - #1724
Open
dqnykamp wants to merge 1 commit into
Open
Conversation
Vendors upstream davidaustinm/prefigure's Rust/WASM compiler (prefig-wasm, native/RaTeX variant) as a git submodule pinned to a specific commit, wrapped in a new packages/prefigure-rust package that builds it via wasm-pack/wireit (mirroring the existing doenetml-worker-rust pattern) and exposes an API matching packages/prefigure's Pyodide-based compilePrefigure()/initPrefigure(). Wires it into prefigureRuntime.ts as a fourth race candidate behind VITE_PREFIGURE_RUST_ENABLED, default disabled. With the flag off, behavior is unchanged: no warmup, no race participation (verified by a unit test asserting the rust module and fetch are never touched). With the flag on, the rust backend warms up and races alongside the existing remote build-service and Pyodide paths, with a fast path once warm, plus console logging of which backend wins each race and its latency. Motivation: prefig-wasm warms up in tens of milliseconds versus Pyodide's multi-second cold start, and could eventually let this package drop the current three-tier loading strategy. This is evaluation-stage: prefig-wasm is ~weeks old, unpublished to npm (hence the vendored submodule), and covers a bounded but real risk of upstream feature gaps, so the flag defaults off and the existing Pyodide/service paths are untouched. Not included: production packaging of the wasm asset (works today because dev serves straight from this package's dist/, which happens to sit next to the vendored pkg/ output; a real production build shipping only dist/* will need a proper asset-URL import, tracked as a follow-up), and no changes to packages/doenetml-print, which has its own independent Pyodide-based PreTeXt compilation path. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Evaluation-stage integration of upstream
davidaustinm/prefigure's Rust/WASM compiler (prefig-wasm, native/RaTeX variant) as a fourth, opt-in and default-off backend for the prefigure graph renderer, alongside the existing remote build-service and Pyodide paths.packages/prefigure-rustpackage: vendorsprefig-wasmvia a git submodule (packages/prefigure-rust/upstream, pinned to a commit — the crate isn't published to npm yet), builds it withwasm-pack/wireit mirroring the existingdoenetml-worker-rustpattern, and wraps it with an API matchingpackages/prefigure'scompilePrefigure()/initPrefigure().prefigureRuntime.ts: adds the rust backend as a race candidate behindVITE_PREFIGURE_RUST_ENABLED(default disabled). With the flag off, behavior is unchanged — verified by a unit test asserting the rust module andfetchare never touched. With it on, the rust backend races the existing paths and a console log reports which backend wins each build and its latency.Why:
prefig-wasmwarms up in tens of milliseconds versus Pyodide's multi-second cold start in local testing, and could eventually let this renderer drop its current three-tier loading strategy entirely.prefig-wasmis only a few weeks old and unpublished, so this lands as an evaluation path behind a flag rather than a replacement.Not included (tracked as follow-ups, not started here):
dist/directly, which happens to sit next to the vendoredpkg/output; a real production build shipping onlydist/*needs a proper Vite asset-URL import instead.packages/doenetml-print's independent Pyodide-based PreTeXt compilation path — untouched.No changeset: the flag defaults off and this changes no default behavior for any user.
Test plan
npm run build -w packages/prefigure-rustandnpm run test -w packages/prefigure-rustnpm run build -w packages/doenetmlnpm run test -w packages/doenetml -- prefigureRuntime(new unit tests covering flag-off no-op and flag-on race participation)VITE_PREFIGURE_RUST_ENABLED=true: graphs render correctly via the rust backend across points/lines/vectors/angles/curves/grids, in both light and dark mode🤖 Generated with Claude Code