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

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


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
kadircet marked an inline comment as done.
Closed by commit rGe2f598bc1b37: [clangd] Record IO precentage for first preamble build of the instance (authored by kadircet).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D122894/new/

https://reviews.llvm.org/D122894

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


Index: clang-tools-extra/clangd/TUScheduler.cpp
===================================================================
--- clang-tools-extra/clangd/TUScheduler.cpp
+++ clang-tools-extra/clangd/TUScheduler.cpp
@@ -112,17 +112,16 @@
 
 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;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D122894.419739.patch
Type: text/x-patch
Size: 1352 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220401/bd120964/attachment.bin>


More information about the cfe-commits mailing list