Skip to content

Compute humanized bytes lazily#593

Draft
dnagoda wants to merge 1 commit into
dc.batch-4-reuse-providerfrom
dc.batch-5-lazy-humanized
Draft

Compute humanized bytes lazily#593
dnagoda wants to merge 1 commit into
dc.batch-4-reuse-providerfrom
dc.batch-5-lazy-humanized

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.


Why

BytesContainer eagerly built a humanized String (pretty-printed JSON or a
hex dump) on every construction, even though it's only needed when a
FunctionRunResult is actually displayed. Batch mode constructs a
BytesContainer per input row and never renders the humanized form, so this was
pure per-row overhead.

What

  • Drop the stored humanized field; replace it with a HumanizedBytes Display
    wrapper that formats on demand.
  • Invalid-JSON output now retains its raw bytes so the wrapper can reproduce the
    previous lossy-UTF8 rendering.
  • Single-run output is byte-for-byte unchanged.

Testing

  • cargo build
  • cargo test

BytesContainer eagerly built a `humanized` String (pretty-printed JSON or a
hex dump) on every construction, even though it is only needed when a
FunctionRunResult is displayed. Batch mode constructs a BytesContainer per
input row and never renders the humanized form, so this was pure per-row
overhead.

Remove the stored `humanized` field and replace it with a HumanizedBytes
Display wrapper that formats on demand. Single-run output is unchanged.
Invalid JSON output now retains its raw bytes so the wrapper can reproduce
the previous lossy-UTF8 rendering.

Verified with:
- cargo build
- cargo test

Assisted-By: devx/c659e918-9568-4750-b122-e3890447348a
@dnagoda dnagoda force-pushed the dc.batch-4-reuse-provider branch from a8174bb to 9d39117 Compare July 6, 2026 23:33
@dnagoda dnagoda force-pushed the dc.batch-5-lazy-humanized branch from 5fea7f9 to 3f69067 Compare July 6, 2026 23:33
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.

1 participant