Skip to content

Add batch mode for processing multiple inputs via JSONL#1

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

Add batch mode for processing multiple inputs via JSONL#1
dnagoda wants to merge 1 commit into
mainfrom
dc.batch-1-jsonl-mode

Conversation

@dnagoda

@dnagoda dnagoda commented Jul 2, 2026

Copy link
Copy Markdown
Owner

📚 Stack (bottom → top)

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

Stacked draft PRs on the fork; review bottom-up. Merge target is Shopify/function-runner once upstream write access is available.


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

@dnagoda

dnagoda commented Jul 6, 2026

Copy link
Copy Markdown
Owner Author

Moved upstream to Shopify#589 now that write access is available. Closing this fork PR.

@dnagoda dnagoda closed this Jul 6, 2026
@dnagoda dnagoda deleted the dc.batch-1-jsonl-mode branch July 6, 2026 17:23
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