enhancement(compiler): record unnest's root instead of a root query for every get #2075
All Vouch review confidence checks passed
Residual risk 0.16 = Change Risk (0.40) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.40 · 279 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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.337
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #2075"
general
weight: 0.35
pront
Summary
ProgramInfo::target_querieslists the paths a program reads, so that targets can prepare only those fields. Two functions didn't fit this model:getrecorded a query for the whole event (.) on every call, as a workaround for paths that are only known at runtime. But the valuegetreads from is an ordinary argument, so its path is already recorded when the argument is compiled:.tagsforget(.tags, path),.forget(., path), and the original path for a variable such astags = .tags.unnestreads the whole target, because it copies the rest of the target around each element, but only the path it was given was recorded. The extra root query fromgethid this whenever a program also calledget.This PR removes the root query for
get. Forunnest, it addsFunctionCompileContext::record_target_query, so a function can record paths it reads beyond its arguments.Unnest::compileuses it to record the root of its target (.or%) once it has the resolved path. This keeps the decision in the function itself, so host functions that happen to share a name aren't affected.This matters for Vector's metric events, where
VrlTargetprepares only the queried fields. With vectordotdev/vector#27264:| Program | Before | After |
|---|---|---|
|
get!(.tags, ["region"])| Correct, but converts every sample of a distribution | Correct, no samples converted ||
tags = .tags; get!(tags, ["region"])| Converts every sample | No samples converted ||
rows = unnest!(.tags.region); [rows[0].name, rows[0].gauge.value]|[null, null]|["load", 3.0]|How did you test this PR?
src/compiler/compiler.rschecktarget_queriesforget,unnest, and a host function also namedunnest, with positional and named arguments.cargo test --libpasses.Runtime::resolve, with and without this change.Does this PR include user-facing changes?
our guidelines.