Skip to content

[Nexthop] benchmark --filter/--filter_file accept the gtest filter grammar - #1434

Open
saty-nexthop wants to merge 1 commit into
facebook:mainfrom
nexthop-ai:benchmark-filter-gtest-grammar
Open

[Nexthop] benchmark --filter/--filter_file accept the gtest filter grammar#1434
saty-nexthop wants to merge 1 commit into
facebook:mainfrom
nexthop-ai:benchmark-filter-gtest-grammar

Conversation

@saty-nexthop

@saty-nexthop saty-nexthop commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Pre-submission checklist

  • I've ran the linters locally and fixed lint errors related to the files I modified in this PR. You can install the linters by running pip install -r requirements-dev.txt && pre-commit install
  • pre-commit run

Summary

benchmark --filter and --filter_file didn't take the filter syntax every other test runner takes. --filter was a single regex and --filter_file matched exact benchmark names, so when a runner wrote *StatsCollection* into a filter file it matched nothing.

Both now take the gtest grammar: include:include:-exclude, with * and ? wildcards. Same thing test_runner.py does when it builds --gtest_filter. Plain regexes still work, because * only gets expanded where it isn't already part of a regex. Rewriting it blindly turns .*Route.* into ..*Route..*, which then matches no name starting with Route. If both flags are given, --filter_file wins, same as on the gtest path.

Second thing, while I was in here: a run where every benchmark is known-bad or unsupported on the platform used to return early and write no results CSV. Callers look for that CSV to decide whether the run produced anything, so this read as an infra failure instead of "this platform doesn't have these benchmarks". It now writes the CSV and reports the skips. It never came up while a single test ran every benchmark, but it does as soon as callers filter down to one family.

Test Plan

275 unit tests pass in fboss/oss/scripts/run_scripts/fboss_test_runner/unittests, covering includes, excludes, multiple patterns, ?, plain regexes, invalid patterns, missing and empty filter files, and the all-unsupported skip path.

@saty-nexthop
saty-nexthop requested a review from a team as a code owner July 29, 2026 07:51
@meta-cla meta-cla Bot added the CLA Signed label Jul 29, 2026
@saty-nexthop
saty-nexthop force-pushed the benchmark-filter-gtest-grammar branch from 6ebda9d to 8ff42c9 Compare July 29, 2026 08:00
Benchmarks could not be filtered the way every other test runner is.
--filter took a single regex and --filter_file took exact benchmark
names, so the wildcard patterns the runners write into a filter file
("*StatsCollection*") matched nothing.

Teach _get_benchmarks_to_run the gtest grammar, mirroring how
test_runner.py feeds --gtest_filter: join filter-file lines with ':',
split on the first '-' into includes and excludes, and expand '*'/'?'
wildcards. Wildcards already part of a regex are left alone so plain
regexes keep their meaning -- naively rewriting '*' turns ".*Route.*"
into "..*Route..*", which stops matching any name beginning with Route.
--filter_file wins when both are given, as on the gtest path.

Also report a run whose benchmarks are all known-bad or unsupported on
this platform as skipped rather than returning with no results file.
Callers decide "did this run produce results?" by looking for the CSV,
so the old early return looked like an infra failure instead of a
platform gap. This never triggered while a single test ran every
benchmark, but it does as soon as callers filter down to one family.

Test Plan: 275 unit tests pass (fboss_test_runner/unittests).
@saty-nexthop
saty-nexthop force-pushed the benchmark-filter-gtest-grammar branch from 8ff42c9 to 5dcf6cd Compare July 29, 2026 08:11
@meta-codesync

meta-codesync Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

@AarjunC has imported this pull request. If you are a Meta employee, you can view this in D114089843.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant