This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Initialize clang-tidy modules only once
ClosedPublic

Authored by kadircet on May 10 2023, 1:44 AM.

Details

Summary

This is showing up on our profiles with ~100ms contribution @95th% for
buildAST latencies.
The patch is unlikely to address it all, but should help with some low-hanging
fruit.

Diff Detail

Event Timeline

kadircet created this revision.May 10 2023, 1:44 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 10 2023, 1:44 AM
kadircet requested review of this revision.May 10 2023, 1:44 AM
sammccall accepted this revision.May 10 2023, 1:52 AM
sammccall added inline comments.
clang-tools-extra/clangd/ParsedAST.cpp
478–483

as written this creates a global destructor

instead, prefer heap-allocating and never freeing (the static variable should be a pointer or non-lifetime-extending reference)

clang-tools-extra/clangd/TidyProvider.cpp
300

same here, avoid the destructor

300

nit: call this DefaultOpts, as it's in general not the opts we're calculating

305

Inverting the if(Provider) check isn't clearer IMO, and it's also not an optimization (return Opts is a copy, vs NewOpts = Opts is a copy + return NewOpts is a NVRO no-op).

Up to you, but I prefer the previous formulation (with the extra copy of defaultopts added at the top)

This revision is now accepted and ready to land.May 10 2023, 1:52 AM
kadircet updated this revision to Diff 520948.May 10 2023, 3:30 AM
kadircet marked 4 inline comments as done.
  • Move ReplayPreambleTests to its own file and move registry to global scope.
This revision was landed with ongoing or failed builds.May 10 2023, 3:39 AM
This revision was automatically updated to reflect the committed changes.