Commit graph

32 commits

Author SHA1 Message Date
Sebastian Herrlinger
df26d7b266 Merge branch 'rust-gc-incremental' into codemode-rust-gc 2026-11-19 16:06:34 +01:00
Sebastian Herrlinger
3b47c29619 docs(codemode): record the psychoscript collector trials 2026-11-19 16:05:32 +01:00
Sebastian Herrlinger
0b343bbade Merge branch 'codemode-rust-gc' into rust-gc-incremental 2026-11-19 14:35:30 +01:00
Sebastian Herrlinger
329bd866f2 test(codemode): keep the many-heaps benchmark on the small programs 2026-11-19 14:34:53 +01:00
Sebastian Herrlinger
8b899e1b58 test(codemode): add a large live set to the memory benchmark 2026-11-19 14:34:40 +01:00
Sebastian Herrlinger
073cbeb11f feat(codemode): add an incremental mark-sweep collector behind gc-incremental 2026-11-19 14:17:24 +01:00
Sebastian Herrlinger
6ca5dee148 test(codemode): add a memory benchmark for long-lived psychoscript runs 2026-11-19 13:13:15 +01:00
Sebastian Herrlinger
ba616f357a docs(codemode): refresh bench results after threading by nesting 2026-11-19 03:34:27 +01:00
Sebastian Herrlinger
47bf86e198 test(codemode): bench programs as futures with --async 2026-11-19 03:32:56 +01:00
Sebastian Herrlinger
34d2637981 feat(codemode): move long stretches of a run's compute to a worker thread, keeping host code on the executor 2026-11-19 03:32:56 +01:00
Sebastian Herrlinger
cf1d29b111 test(codemode): measure the native stack compiling and re-entrant calls need 2026-11-19 03:20:02 +01:00
Sebastian Herrlinger
c01c31121e feat(codemode): keep unpaired surrogates in namespace paths, error names, RegExp sources, bindings, metadata and durable data 2026-11-19 03:11:19 +01:00
Sebastian Herrlinger
9257f8889f feat(codemode): keep unpaired surrogates in the result and the logs (Data, HostString) 2026-11-19 02:53:56 +01:00
Sebastian Herrlinger
d4f4efab9e chore(codemode): record the bench against the reference's language runtime 2026-11-19 01:55:19 +01:00
Sebastian Herrlinger
04e3d5b5a0 chore(codemode): compare the Rust bench with the reference's language runtime 2026-11-19 01:54:19 +01:00
Sebastian Herrlinger
6d7e96a399 refactor(codemode): make the Rust crate the language layer only
The crate becomes the Rust implementation of the reference's language layer (`src/language/`): its public API is
the Rust form of `Language` (`Runtime::make` with `globals(run)`, modules, limits and translation; `HostFunction`
for `Host.fn` with sync, async and sync-thenable types, idempotent, constructible and takes-functions;
`DurableFunction`; `Namespace`; `Failure` for `Host.fail` and `Host.missing`; `Run` with its metadata; programs,
suspend and resume; snapshots). Code Mode (tools, schemas, the catalog, `search`, OpenAPI, hooks, max tool calls,
extensions) is removed, and the language files move from `src/language/` to `src/`.

Host calls follow the reference's language runtime: arguments cross under the runtime's translation (functions and
promises fail the call unless dropped or awaited), a function from a result crosses back only to a function that
takes functions, async and durable calls start at the next handover, sync work can block (`Returned::Block`) or
stay pending (`Returned::Pending`), and a suspend is refused while a call that can't be detached runs. Namespace
paths carry their root label, and their `keys` may fail. Snapshots save the run's metadata and its calls by global
path, and restart them by resolving that path again.

The replays define the generators' host globals (`conformance/reference.rs` shares `tools` with
`conformance/reference.ts`): the cases, `host.json`, `boundary.json` and `streaming.json`. `tests/host.rs` mirrors
the reference's `test/language.test.ts`; the API tests are ported, and the Code Mode tests are removed.
2026-11-19 01:54:11 +01:00
Sebastian Herrlinger
68af5876c5 chore(codemode): run the reference bench programs through the language runtime 2026-11-19 01:53:46 +01:00
Sebastian Herrlinger
ecadfe2b48 chore(codemode): regenerate bench results after the Map/Set and string speedups 2026-11-18 18:56:14 +01:00
Sebastian Herrlinger
2a974f83f1 chore(codemode): regenerate bench results after native frames 2026-11-18 18:56:14 +01:00
Sebastian Herrlinger
88e9f8d5e3 test(codemode): check libm-dependent pow and hypot cases on Linux only 2026-11-18 18:56:12 +01:00
Sebastian Herrlinger
1f08a7a7b5 chore(codemode): say the Rust bench tools validate the reference's schemas
tools() in bench/src/main.rs registers the JSON Schemas the reference's Effect Schemas render to, so the tool fan-out footnote and the plugin-event note no longer say the Rust side skips validation.
2026-11-18 18:56:12 +01:00
Sebastian Herrlinger
76262a1b7f test(codemode): regenerate the benchmark results
bash bench/compare.sh on an Apple M5 Max (macOS 26.7.1, bun 1.4.3), formatted with the repository's prettier.
2026-11-18 18:56:12 +01:00
Sebastian Herrlinger
bd4f8b719e chore(codemode): let compare.sh run on macOS
It read the CPU and memory from /proc, sizes with GNU stat, peak RSS with GNU time and cold starts with bash 5's $EPOCHREALTIME. On macOS it now asks sysctl, BSD stat and time, and times cold starts with perl's clock around each run.
2026-11-18 18:56:11 +01:00
kommander
2c721e5b69 feat(codemode): collate localeCompare like the reference's host
localeCompare used a case-folding heuristic that disagreed with the
reference on 634 of 4,841 sampled pairs (accents, punctuation, canonical
equivalence, scripts). It now uses ICU4X's root collation, which the
reference's host uses for its en-US default, and agrees on all of them.

Dependency: icu_collator 2.4 with compiled data (pure Rust, Unicode's
ICU4X). It adds 1,247,048 bytes to the stripped embed example
(4,785,968 -> 6,033,016; bench/RESULTS.md (d) updated); nearly all of that is the root collation table,
so generating data for the root locale alone saves under 1 KB.
2026-11-18 18:56:11 +01:00
kommander
7c0a0fc3af perf(codemode): compile tool schemas once and keep host calls off the copy path
Schema::validated compiles its document into a validator once, so checking a
value does no keyword lookups and builds a path only when it fails. A failed
host call is boxed, so a successful one stays small in the inbox; synchronous
tools share one context; a program compiles when it is made and borrows its
source; the run id is made on first use.

The benchmark tools now declare the reference's schemas, so tool fan-out
also validates each input and output, as the reference does.
2026-11-18 18:54:15 +01:00
kommander
8bc1023f3d Merge the test262 runner into the host API work 2026-11-18 18:54:15 +01:00
kommander
e336bbafd1 feat(codemode): add schema tools, search, hooks, async host calls and extensions to the Rust port
Tools take validating or render-only JSON Schemas (the Rust form of Effect
Schemas and the reference's JsonSchema), render byte-identical TypeScript
signatures, and report InvalidToolInput and InvalidToolOutput. Namespaces,
freeform tools, the catalog, toolExpression, searchSignature and the BM25
search built-in follow tool-runtime.ts; conformance/catalog.ts regenerates
the expectations from the reference.

Tools and extension globals may return futures. execute_async runs on any
executor; execute drives it with a small built-in block_on, and a shared
timer thread enforces timeouts while host work is pending. Dropping a run
cancels its calls, which after hooks see as interrupted.

Extensions cross values as copies both ways, including functions in results,
errors, maps and sets, and programs load them with import, require and
import() by Node module name. Runtime::program adds the reference's
program API with run ids.
2026-11-18 18:54:08 +01:00
Sebastian
7c9abf305b test(codemode): regenerate the benchmark results with variants and plugin events 2026-11-18 18:53:57 +01:00
Sebastian
68482e90c4 fix(codemode): stop compare.sh flagging its own output as an uncommitted change 2026-11-18 18:53:57 +01:00
Sebastian
7c47583bd6 chore(codemode): pin the Rust toolchain and prepare compare.sh for CI
Runs fmt, Clippy and the tests including conformance; regenerates every
conformance expectation from the reference and fails on a diff; runs the
test262 parity check; and runs the benchmarks into the job summary without
gating. The toolchain is pinned in rust-toolchain.toml with a minimal
profile, and every cargo call is --locked.



The workflow file itself follows in a separate commit.
2026-11-18 18:53:57 +01:00
Sebastian
85ffd4dc70 test(codemode): add perturbed variants and a plugin-event benchmark
Each bench program gets an equivalent, differently written variant in
bench/variants/, run next to its original on both implementations, with the
variant / original ratio per side. A plugin-event benchmark runs the
conformance reducer with a git.status tool as a 226-byte and a 3 KB source.
RESULTS.md labels medians, mins and means, computes speed-ups from medians
only, and notes that the reference tools validate through Effect Schema.
2026-11-18 18:53:57 +01:00
Sebastian
f71cdee242 feat(codemode): add embeddable Rust port 2026-11-18 18:53:56 +01:00