Skip to content

Add batch mode for JSONL function runs#595

Draft
dnagoda wants to merge 1 commit into
mainfrom
dc.batch-mode
Draft

Add batch mode for JSONL function runs#595
dnagoda wants to merge 1 commit into
mainfrom
dc.batch-mode

Conversation

@dnagoda

@dnagoda dnagoda commented Jul 6, 2026

Copy link
Copy Markdown

📚 Stack (bottom → top)

  1. Add batch mode for JSONL function runs #595 Add batch mode for processing multiple inputs via JSONL
  2. Preserve JSON input object order #590 Preserve JSON input object order
  3. Refine batch failure handling #591 Refine batch failure handling
  4. Reuse the compiled provider across runs #592 Reuse the compiled provider across runs
  5. Compute humanized bytes lazily #593 Compute humanized bytes lazily
  6. Add minimal batch output with --batch-full-output opt-in #594 Add minimal batch output with --batch-full-output opt-in

Stacked PRs — review bottom-up.


Refs shop/issues-checkout#13420

Why

The function-runner is used by function-rerunner to replay production
function inputs for Checkout Blocks migration parity. Replaying hundreds of
thousands of inputs one process-per-input is dominated by process startup and
Wasm engine/module compilation, which is identical work repeated for every row.

What

Add a --batch mode that reads newline-delimited JSON (JSONL) inputs from a
file (--input) or stdin and runs the function once per line:

  • Creates the Wasmtime Engine and loads the Module once, then reuses
    them across every input row — the expensive setup is amortized.
  • Infers the codec (JSON vs. MessagePack) once from the module's imports.
  • Streams one compact JSON result per line to stdout (JSONL out), so callers
    can parse results incrementally.
  • --batch-continue-on-error keeps processing on per-line read/parse/execute
    failures, emitting a {"success":false,"error":...} record for the failing
    line; without it, batch mode fails fast on the first error.
  • Prints a Batch complete: N processed, S successful, E errors summary to
    stderr so it never contaminates the JSONL on stdout.

Single-run behavior is unchanged — the existing path is factored into
run_single_mode and shares the same engine/module setup.

Testing

  • cargo test
  • cargo build --release

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.

2 participants