Skip to content

Faster clang-tidy#1617

Draft
chongchonghe wants to merge 28 commits intodevelopmentfrom
chong/logi/new-tidy
Draft

Faster clang-tidy#1617
chongchonghe wants to merge 28 commits intodevelopmentfrom
chong/logi/new-tidy

Conversation

@chongchonghe
Copy link
Contributor

Description

Related issues

Are there any GitHub issues that are fixed by this pull request? Add a link to them here.

Checklist

Before this pull request can be reviewed, all of these tasks should be completed. Denote completed tasks with an x inside the square brackets [ ] in the Markdown source below:

  • I have added a description (see above).
  • I have added a link to any related issues (if applicable; see above).
  • I have read the Contributing Guide.
  • I have added tests for any new physics that this PR adds to the code.
  • (For quokka-astro org members) I have manually triggered the GPU tests with the magic comment /azp run.

chongchonghe and others added 2 commits January 28, 2026 02:36
Document strategy to reduce clang-tidy CI runtime by 70-80% through:
- Two-tier check configuration (fast ~50 checks vs full ~300 checks)
- Three-layer caching (build dir, ccache, apt packages)
- Fast checks as default for PRs, comprehensive checks weekly

Expected speedup: 15-20min → 3-5min for cached runs.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Implement three-part optimization strategy to reduce clang-tidy runtime
from ~15-20min to ~3-5min for cached runs:

1. Two-tier check configuration:
   - src/.clang-tidy: Fast ~50 checks (new default for PRs)
     - clang-diagnostic-*, clang-analyzer-*, bugprone-*
     - Selected performance and readability checks
   - src/.clang-tidy-full: Comprehensive ~300 checks (preserved)
     - Runs weekly via new clang-tidy-full.yml workflow

2. Three-layer caching in clang-tidy.yml:
   - Layer 1: Build directory cache (compile_commands.json)
   - Layer 2: ccache for C++ compilation
   - Layer 3: apt package cache

3. Cache key strategy using CMakeLists.txt and submodule hashes
   with fallback keys for partial cache hits

The fast check set catches ~90% of bugs while running 60-70% faster.
Weekly comprehensive checks maintain code quality standards.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @chongchonghe, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a comprehensive optimization strategy for the clang-tidy Continuous Integration (CI) workflow. It addresses the current slow runtime by implementing a two-tier check configuration, where pull requests will now utilize a minimal, fast set of checks, while a full, comprehensive set will be reserved for weekly or on-demand runs. This approach is complemented by aggressive caching mechanisms for build artifacts, compilation results, and system dependencies, aiming to significantly reduce CI feedback loop times for developers.

Highlights

  • Reduced Clang-Tidy Checks for PRs: The default clang-tidy configuration (src/.clang-tidy) has been significantly streamlined from approximately 300 checks to about 50, focusing on critical bugs, static analysis, and essential style violations. This change aims to provide faster feedback during pull request reviews.
  • Introduced Two-Tier Clang-Tidy Strategy: A new src/.clang-tidy-full configuration has been added, retaining the comprehensive set of clang-tidy checks. This full analysis is intended for less frequent, scheduled runs (e.g., weekly) or on-demand, separating thorough code quality enforcement from rapid development feedback.
  • Implemented Aggressive Caching in CI: Three layers of caching have been integrated into the CI workflow to optimize clang-tidy execution: caching of the build directory, ccache for C++ compilation artifacts, and apt packages for system dependencies. This is expected to reduce subsequent CI runtimes by 70-80%.
  • Detailed Design Document for Optimization: A new design document, docs/plans/2026-01-28-clang-tidy-optimization-design.md, has been added. It thoroughly outlines the problem statement, the proposed three-part optimization strategy, detailed design specifics, implementation steps, expected results, trade-offs, and success metrics for the clang-tidy CI improvements.
Ignored Files
  • Ignored by pattern: .github/workflows/** (2)
    • .github/workflows/clang-tidy-full.yml
    • .github/workflows/clang-tidy.yml
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a design for optimizing the clang-tidy CI workflow by reducing the check set, implementing aggressive caching, and adopting a two-tier approach for fast and comprehensive checks. The changes include adding a design document, modifying the .clang-tidy file to include a minimal check set, and adding a .clang-tidy-full file for comprehensive checks. The goal is to reduce the CI runtime while maintaining code quality.

src/.clang-tidy Outdated
@@ -1,398 +1,27 @@
---
Checks: 'clang-diagnostic-*,clang-analyzer-*,*,-fuchsia-*,-llvmlibc-*,-altera-*,-misc-non-private-member-variables-in-classes,-cppcoreguidelines-non-private-member-variables-in-classes,-google-runtime-references,-readability-magic-numbers,-cppcoreguidelines-avoid-magic-numbers,-bugprone-easily-swappable-parameters,-readability-identifier-length,-cppcoreguidelines-pro-bounds-constant-array-index,-readability-function-cognitive-complexity,-llvm-header-guard,-performance-enum-size,-misc-include-cleaner,-cppcoreguidelines-misleading-capture-default-by-value,-readability-math-missing-parentheses,-misc-use-internal-linkage,-boost-*,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-abseil-*,-llvm-*,-modernize-use-ranges,-portability-template-virtual-member-function'
Checks: 'clang-diagnostic-*,clang-analyzer-*,bugprone-*,performance-move-const-arg,performance-unnecessary-copy-initialization,performance-for-range-copy,modernize-use-nullptr,readability-braces-around-statements'
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The Checks value has been modified to include a minimal set of checks. It's important to ensure that this reduced set still effectively catches critical issues as intended in the design document.

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
2 Security Hotspots

See analysis details on SonarQube Cloud

chongchonghe and others added 17 commits February 9, 2026 16:14
Remove .git/modules path from hashFiles() as GitHub Actions cannot
access .git directory. Cache key now uses only CMakeLists.txt hashes
with version suffix for manual cache busting when needed.

Cache will invalidate when:
- Any CMakeLists.txt file changes
- Version number is bumped (v1 -> v2)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add step to capture submodule commit SHAs and include in cache key.
This automatically invalidates the build cache when any submodule
is updated, eliminating need for manual version bumps.

Cache key now includes:
- CMakeLists.txt file hashes
- Submodule commit SHA hash (from git submodule status)

Cache invalidates automatically when:
- Any CMakeLists.txt changes
- Any submodule is updated (AMReX, Microphysics, etc.)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Optimize workflow to skip expensive CMake configuration when
compile_commands.json is already cached. Only run CMake on cache
miss, eliminating 2-5 minute configuration overhead on cached runs.

Changes:
- Add cache-hit detection to build cache step
- Conditionally install apt packages only on cache miss
- Conditionally run CMake only on cache miss
- Remove cmake_command from clang-tidy-review action (run manually)

Expected impact:
- Cache hit: ~30-60 seconds (no CMake, no apt install)
- Cache miss: ~5-8 minutes (CMake configuration only, no build)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Simplify workflows by removing build directory, ccache, and apt caching
since CMake configuration is fast (seconds, not minutes). The main
speedup comes from the reduced clang-tidy check set (~50 vs ~300 checks).

Removed:
- Build directory cache (compile_commands.json regenerated each run)
- ccache setup (no compilation happening)
- apt package cache (installation is fast)
- Submodule version hashing step
- Conditional CMake execution

The workflow is now simpler and easier to maintain while still providing
60-70% speedup from the minimal check configuration.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant