Skip to content

perf: discard jinja rendered SQL output - #184

Merged
eitsupi merged 1 commit into
mainfrom
perf/jinja-discard-output
Aug 30, 2026
Merged

perf: discard jinja rendered SQL output#184
eitsupi merged 1 commit into
mainfrom
perf/jinja-discard-output

Conversation

@eitsupi

@eitsupi eitsupi commented Aug 30, 2026

Copy link
Copy Markdown
Owner

Summary

  • write rendered Jinja output to an I/O sink instead of allocating an unused SQL String
  • keep template evaluation, extraction callbacks, completion status, and partial results unchanged
  • use MiniJinja 2.24's public, non-deprecated render_captured_to API

Why

dlin renders each model template to collect side effects from the ref, source, and config stubs. It does not use the rendered SQL text. Template::render nevertheless builds and returns the complete output string.

render_captured_to((), std::io::sink()) evaluates the same compiled template and preserves render errors and callback side effects while discarding only the output bytes. The existing pass-local extraction reset still runs after both successful and failed renders.

Correctness

The macro-heavy cache suite passed semantic equivalence for no-cache, persistent-cold, and persistent-warm execution, together with SQL, macro, and vars invalidation probes. Existing tests cover successful extraction, partial extraction after render failure, and isolation between full and incremental passes.

Performance

The current macro-heavy fixture contains short rendered SQL, so the allocation removal is below its timing resolution. An 80-pair randomized comparison produced a candidate/base median ratio of 1.0021, with no measurable improvement or regression. The change removes output storage proportional to rendered SQL size without changing the dominant template evaluation work.

Verification

  • cargo test --workspace --locked
  • cargo fmt --all --check
  • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings
  • macro-heavy cache benchmark, 10 runs and 2 warmups

@eitsupi eitsupi changed the title perf(jinja): discard rendered SQL output perf: discard jinja rendered SQL output Aug 30, 2026
@eitsupi
eitsupi merged commit 97175a5 into main Aug 30, 2026
13 checks passed
@eitsupi
eitsupi deleted the perf/jinja-discard-output branch August 30, 2026 01:41
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