Skip to content

Speedup devtool checkstyle#5853

Merged
Manciukic merged 6 commits into
firecracker-microvm:mainfrom
Manciukic:speedup-checkstyle
Apr 29, 2026
Merged

Speedup devtool checkstyle#5853
Manciukic merged 6 commits into
firecracker-microvm:mainfrom
Manciukic:speedup-checkstyle

Conversation

@Manciukic

Copy link
Copy Markdown
Contributor

Changes

The checkstyle step had several bottlenecks from spawning excessive subprocesses and doing redundant work. These changes reduce wall-clock time by consolidating them.

Unused metrics check (fcmetrics.py, test_rust.py) — test_unused_metrics spawned one grep -RPzo per metric field (~208 subprocesses, each scanning the entire src/ tree). Replaced with a single grep -rPn that matches all field names at once, with Python-side filtering to exclude comments, string literals, and test/definition files. Also renamed the misleading is_file_production to is_file_test_or_definition.

Markdown formatting (test_markdown.py) — test_markdown_style ran mdformat + diff per file. Replaced with a single mdformat --check invocation for all files.

CI orchestration (devtool, test.sh) — Consolidated three separate cmd_test invocations (style tests, doctests, clippy) into one pytest run. Added FC_TEST_SKIP_ARTIFACT_COPY to skip copying build artifacts for style-only tests that don't need them.

Before:

real	1m35.469s
user	0m0.199s
sys 	0m0.362s

After:

real	0m30.778s
user	0m0.087s
sys 	0m0.136s

Reason

Make checkstyle faster to speed up automated rebases.

License Acceptance

By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache 2.0 license. For more information on following Developer
Certificate of Origin and signing off your commits, please check
CONTRIBUTING.md.

PR Checklist

  • I have read and understand CONTRIBUTING.md.
  • I have run tools/devtool checkbuild --all to verify that the PR passes
    build checks on all supported architectures.
  • I have run tools/devtool checkstyle to verify that the PR passes the
    automated style checks.
  • I have described what is done in these changes, why they are needed, and
    how they are solving the problem in a clear and encompassing way.
  • I have updated any relevant documentation (both in code and in the docs)
    in the PR.
  • I have mentioned all user-facing changes in CHANGELOG.md.
  • If a specific issue led to this PR, this PR closes the issue.
  • When making API changes, I have followed the
    Runbook for Firecracker API changes.
  • I have tested all new and changed functionalities in unit tests and/or
    integration tests.
  • I have linked an issue to every new TODO.

  • This functionality cannot be added in rust-vmm.

Replace per-field grep in test_unused_metrics (one subprocess per metric
field, ~208 invocations) with a single grep that matches all field names
at once and filters results in Python.

Changes in fcmetrics.py:
- Remove is_metric_used() which ran grep -RPzo per field
- Add find_unused_metrics() which builds a combined alternation of all
  field names and runs a single grep -rPn across src/
- Filter grep output in Python to skip test files and metrics definition
  files (via renamed is_file_test_or_definition), comment lines, and
  string literals
- Rename is_file_production to is_file_test_or_definition to reflect
  what it actually checks

Changes in test_rust.py:
- Simplify test_unused_metrics to call find_unused_metrics() directly
- Remove unused imports (defaultdict, extract_fields,
  find_metrics_files, is_metric_used)

Signed-off-by: Riccardo Mancini <mancio@amazon.com>
test_markdown_style was spawning a bash+diff+mdformat subprocess for
each of the 66 markdown files individually (23s). Pass all files to
mdformat --check in one call (~4s).

Signed-off-by: Riccardo Mancini <mancio@amazon.com>
checkstyle ran three separate cmd_test invocations (style, doctests,
clippy), each launching a container, copying 2.3GB of artifacts, and
starting pytest. Style checks don't need artifacts at all.

- Add FC_TEST_SKIP_ARTIFACT_COPY=1 support to test.sh
- Set it in cmd_checkstyle to skip the artifact copy
- Merge the three cmd_test calls into a single pytest invocation

Signed-off-by: Riccardo Mancini <mancio@amazon.com>
@Manciukic Manciukic force-pushed the speedup-checkstyle branch from 577fb02 to 2b1cd10 Compare April 23, 2026 13:18
@codecov

codecov Bot commented Apr 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.87%. Comparing base (0f72a01) to head (ce60850).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5853   +/-   ##
=======================================
  Coverage   82.87%   82.87%           
=======================================
  Files         276      276           
  Lines       29728    29728           
=======================================
  Hits        24637    24637           
  Misses       5091     5091           
Flag Coverage Δ
5.10-m5n.metal 83.18% <ø> (+<0.01%) ⬆️
5.10-m6a.metal 82.50% <ø> (ø)
5.10-m6g.metal 79.78% <ø> (+<0.01%) ⬆️
5.10-m6i.metal 83.18% <ø> (+<0.01%) ⬆️
5.10-m7a.metal-48xl 82.49% <ø> (ø)
5.10-m7g.metal 79.78% <ø> (ø)
5.10-m7i.metal-24xl 83.15% <ø> (ø)
5.10-m7i.metal-48xl 83.15% <ø> (+<0.01%) ⬆️
5.10-m8g.metal-24xl 79.78% <ø> (ø)
5.10-m8g.metal-48xl 79.78% <ø> (ø)
5.10-m8i.metal-48xl 83.15% <ø> (ø)
5.10-m8i.metal-96xl 83.15% <ø> (ø)
6.1-m5n.metal 83.20% <ø> (+<0.01%) ⬆️
6.1-m6a.metal 82.53% <ø> (+<0.01%) ⬆️
6.1-m6g.metal 79.78% <ø> (-0.01%) ⬇️
6.1-m6i.metal 83.19% <ø> (ø)
6.1-m7a.metal-48xl 82.52% <ø> (ø)
6.1-m7g.metal 79.78% <ø> (-0.01%) ⬇️
6.1-m7i.metal-24xl 83.21% <ø> (+<0.01%) ⬆️
6.1-m7i.metal-48xl 83.22% <ø> (+<0.01%) ⬆️
6.1-m8g.metal-24xl 79.78% <ø> (ø)
6.1-m8g.metal-48xl 79.78% <ø> (ø)
6.1-m8i.metal-48xl 83.21% <ø> (+<0.01%) ⬆️
6.1-m8i.metal-96xl 83.21% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Manciukic Manciukic marked this pull request as ready for review April 23, 2026 14:55
@Manciukic Manciukic added the Status: Awaiting review Indicates that a pull request is ready to be reviewed label Apr 23, 2026
@Manciukic Manciukic enabled auto-merge (rebase) April 28, 2026 17:37
@Manciukic Manciukic merged commit f599f3b into firecracker-microvm:main Apr 29, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Status: Awaiting review Indicates that a pull request is ready to be reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants