← Back to Pull requests

enhancement(transforms): Split mutable state, remove deep transform clones in Runner #27267

Closed
unknown closed this pull request without merging on Nov 23, 2026 05:25 UTC
View on GitHub
unknown unknown commented on Nov 19, 2026 06:23 UTC
Author

Summary


Split immutable, sharable parts of transforms and mutable state. In Runner::run_concurrently(), don't clone the transform; SyncTransform's are now immutable, shared over Arc, and ErasedSyncTransform creates a fresh owned mutable state per batch. It then runs the transform with this mutable state.

In bench remap/huge that this PR added, it improved throughput by over 40x on Ryzen AI 9 HX 370, 24 workers, batch size 256. Per-batch time 4.09 ms -> 78 µs.
In our full config, Kafka source + ElasticSearch sink with memory buffer, throughput increased by ~300%.

It achieves so by removing two related bottlenecks:

1. No more serial transform cloning in Runner::run_concurrently()
2. For large or complex transforms, such as remap with a large VRL program, it allows workers to share one VRL Program, eliminating work cloning the VRL syntax tree.

Assisted by GPT-6.1 Astra and Sol, and I reviewed the changes.

Vector configuration


Proprietary to my employer; in summary the remap transform is automatically generated, about 300KB, and has over 2,000 if's alone.

Example:

if .service.type == "foo" && .project.code == "bar" {
    if exists(.message) && .message != null && .message != false {
      _ls1, _ls1_err = parse_json((to_string(get!(., ["message"])) ?? ""))
      if _ls1_err == null {
          ...
      }
    }
    (repeating)
}
(previous block repeats 100+ times)

How did you test this PR?


Full cargo nextest run passed (sinks::http::tests::json_zlib_compression_with_payload_wrapper flaky but unrelated); Vector 0.61 with this patch backported is currently running well in our testing environment.

Help needed / future work


Removing the blocking self.transform.clone() caused coordinator to spend less time blocking, which is intended; however this caused remap/add_fields and remap/parse_json to become 5-11% slower. This is due to producer having less time to populate input_rx -> there are less events per batch -> more CPU time per event (in my testing went from ~21 events / batch to ~13.)
Clearly there's a bottleneck on its producer side. The transform coordinator can also make use of bounded wait to allow the buffer to fill up.

Does this PR include user facing changes?


  • Yes. Please add a changelog fragment based on our guidelines.

  • For a new deprecation announcement, follow the deprecation policy and add a deprecation.d/ notice instead.
  • No. A maintainer will apply the no-changelog label to this PR.
  • Diff: 335 lines (+251 / -84) across 4 files Reviewer: pront Review duration: 5702m
    All Vouch review confidence checks passed
    Residual risk 0.17 = Change Risk (0.42) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.42 · 335 lines diff across 4 files
    0.42
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.348
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #27267"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 42.2% (MEDIUM) · Higher = larger blast radius
    42.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 16.7% · Safe to merge
    16.7%