Skip to content

fix(tests): Fix return values for stdlib benchmarks#1814

Open
JakubOnderka wants to merge 5 commits into
vectordotdev:mainfrom
JakubOnderka:fix-bench
Open

fix(tests): Fix return values for stdlib benchmarks#1814
JakubOnderka wants to merge 5 commits into
vectordotdev:mainfrom
JakubOnderka:fix-bench

Conversation

@JakubOnderka

Copy link
Copy Markdown
Contributor

Summary

Many benchmarks for stdlib functions was wrong, because return value is checked just when doing benchmarking in debug mode.

Change Type

  • Bug fix
  • New feature
  • Non-functional (chore, refactoring, docs)
  • Performance

Is this a breaking change?

  • Yes
  • No

How did you test this PR?

cargo bench --features="default test" --bench stdlib

Does this PR include user facing changes?

  • Yes. Please add a changelog fragment based on
    our guidelines.
  • No. A maintainer will apply the "no-changelog" label to this PR.

Checklist

@JakubOnderka JakubOnderka marked this pull request as ready for review June 13, 2026 07:42
@JakubOnderka JakubOnderka requested a review from a team as a code owner June 13, 2026 07:42

@pront pront left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@pront pront added the no-changelog Changes in this PR do not need user-facing explanations in the release changelog label Jun 15, 2026
@pront pront enabled auto-merge June 15, 2026 14:57

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a561e735b5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/compiler/test_util.rs

// Checks if function returns correct result before starting benchmarking
let got = expression.resolve(&mut ctx).map_err(|e| e.to_string());
assert_eq!(got, want);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Use tolerant checks for benchmark float results

With this unconditional assert_eq! in the benchmark harness, release cargo bench --features="default test" --bench stdlib -- --test now aborts before measuring later functions when a benchmark returns a floating value that differs by one f64 ulp from the literal expectation; I ran that command and it panicked at vrl_stdlib/functions/shannon_entropy/default with 3.7369879306358205 vs 3.736987930635821. The previous check was only a debug_assert_eq!, so exact equality here makes the stdlib benchmark suite fail in normal bench runs unless floating results are compared with tolerance or handled specially.

Useful? React with 👍 / 👎.

Comment thread benches/stdlib.rs
" 0.042 upstream_addr=10.0.1.55:8080 upstream_status=200 request_id=req-abc123def456",
);
const PARSE_REGEX_SINGLE_MATCH_PATTERN: &str = "(?P<number>.*?) group";
const PARSE_REGEX_SINGLE_MATCH_PATTERN: &str = r"(?P<number>[^\s-]*?) group";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep benchmarking the documented parse_regex pattern

This shared constant also feeds the parse_regex/single_match benchmark, while the documented example and unit test still use (?P<number>.*?) group in src/stdlib/parse_regex.rs. That old pattern already returns {"number":"first"} for the single-match case, so changing it here only alters the workload being measured (lazy wildcard vs. negated character class) and makes future parse_regex timings incomparable with previous runs; use a separate pattern for the parse_regex_all case if that benchmark needs different captures.

Useful? React with 👍 / 👎.

@pront pront added the stdlib: chunks VRL stdlib function: chunks label Jun 16, 2026
@pront

pront commented Jun 16, 2026

Copy link
Copy Markdown
Member

Please see https://github.com/vectordotdev/vrl/blob/main/AI_POLICY.md#ai-review-comments for un-resolved comments.

@pront pront added the meta: awaiting author Pull requests that are awaiting their author. label Jun 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

meta: awaiting author Pull requests that are awaiting their author. no-changelog Changes in this PR do not need user-facing explanations in the release changelog stdlib: chunks VRL stdlib function: chunks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants