Skip to content

Performance

June Rhodes edited this page Jun 28, 2024 · 2 revisions

While we haven't done any official benchmarking to compare like-for-like, our own testing with .clang-rules shows the static analysis this fork runs to be extremely performant, more-so than other static analysis options:

  • It is orders of magnitude faster than running external/separate static analysis tools such as clang-tidy.
    • Since static analysis happens as part of compilation, you don't have the redundancy of parsing the C++ code again just for a static analysis step. For projects with large translation units (such as Unreal Engine), this is a huge performance boost.
  • It is faster than other built-in static analysis options.
    • Rules defined in .clang-rules only run on top-level declarations that actually have the rules applied to them based on the path of the file that the declaration was located in. If a top-level declaration is in a file that has no .clang-rules in the file hierarchy, it is entirely skipped and no AST matcher code runs against it.
    • In our local testing, translation units that had no rules applied spent a fraction of their time calculating what rules apply (milliseconds for a multi-second compilation). This allows you to safely use .clang-rules in only parts of your code base, with no performance impact when compiling files with no applicable static analysis rules.
    • For top-level declarations that have at least one rule applied, static analysis for that top-level declaration is run on a pool of background threads, allowing static analysis to complete extremely quickly even when different rulesets apply to different parts of the translation unit.
  • It is compatible with the Unreal Build Accelerator.
    • Since the binary is just clang.exe/clang-cl.exe, it works with the UnrealBuildTool and Unreal Build Accelerator, and your compilation can be distributed across multiple machines as it would under normal Clang.
Clone this wiki locally