[clang-tools-extra] e2f598b - [clangd] Record IO precentage for first preamble build of the instance

Kadir Cetinkaya via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 1 06:13:36 PDT 2022


Author: Kadir Cetinkaya
Date: 2022-04-01T15:12:37+02:00
New Revision: e2f598bc1b377f7e5fe2f7044fb653faf3c18bb6

URL: https://github.com/llvm/llvm-project/commit/e2f598bc1b377f7e5fe2f7044fb653faf3c18bb6
DIFF: https://github.com/llvm/llvm-project/commit/e2f598bc1b377f7e5fe2f7044fb653faf3c18bb6.diff

LOG: [clangd] Record IO precentage for first preamble build of the instance

Differential Revision: https://reviews.llvm.org/D122894

Added: 
    

Modified: 
    clang-tools-extra/clangd/TUScheduler.cpp

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clangd/TUScheduler.cpp b/clang-tools-extra/clangd/TUScheduler.cpp
index d905a58fea50b..928ab56d21ae3 100644
--- a/clang-tools-extra/clangd/TUScheduler.cpp
+++ b/clang-tools-extra/clangd/TUScheduler.cpp
@@ -112,17 +112,16 @@ constexpr trace::Metric PreambleBuildFilesystemLatencyRatio(
 
 void reportPreambleBuild(const PreambleBuildStats &Stats,
                          bool IsFirstPreamble) {
-  static llvm::once_flag OnceFlag;
-  llvm::call_once(OnceFlag, [&] {
-    PreambleBuildFilesystemLatency.record(Stats.FileSystemTime, "first_build");
-  });
+  auto RecordWithLabel = [&Stats](llvm::StringRef Label) {
+    PreambleBuildFilesystemLatency.record(Stats.FileSystemTime, Label);
+    if (Stats.TotalBuildTime > 0) // Avoid division by zero.
+      PreambleBuildFilesystemLatencyRatio.record(
+          Stats.FileSystemTime / Stats.TotalBuildTime, Label);
+  };
 
-  const std::string Label =
-      IsFirstPreamble ? "first_build_for_file" : "rebuild";
-  PreambleBuildFilesystemLatency.record(Stats.FileSystemTime, Label);
-  if (Stats.TotalBuildTime > 0) // Avoid division by zero.
-    PreambleBuildFilesystemLatencyRatio.record(
-        Stats.FileSystemTime / Stats.TotalBuildTime, Label);
+  static llvm::once_flag OnceFlag;
+  llvm::call_once(OnceFlag, [&] { RecordWithLabel("first_build"); });
+  RecordWithLabel(IsFirstPreamble ? "first_build_for_file" : "rebuild");
 }
 
 class ASTWorker;


        


More information about the cfe-commits mailing list