[PATCH] D88413: [clangd] Add a metric for tracking memory usage
Kadir Cetinkaya via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 28 06:17:14 PDT 2020
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: cfe-commits, usaxena95, arphaman.
Herald added a project: clang.
kadircet requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D88413
Files:
clang-tools-extra/clangd/support/Trace.cpp
clang-tools-extra/clangd/support/Trace.h
Index: clang-tools-extra/clangd/support/Trace.h
===================================================================
--- clang-tools-extra/clangd/support/Trace.h
+++ clang-tools-extra/clangd/support/Trace.h
@@ -68,6 +68,10 @@
const llvm::StringLiteral LabelName;
};
+/// Convenient helper for collecting memory usage metrics from across multiple
+/// components. Results are recorded under a metric named "memory_usage".
+void recordMemoryUsage(double Value, llvm::StringRef ComponentName);
+
/// A consumer of trace events and measurements. The events are produced by
/// Spans and trace::log, the measurements are produced by Metrics::record.
/// Implementations of this interface must be thread-safe.
Index: clang-tools-extra/clangd/support/Trace.cpp
===================================================================
--- clang-tools-extra/clangd/support/Trace.cpp
+++ clang-tools-extra/clangd/support/Trace.cpp
@@ -326,6 +326,13 @@
Context EventTracer::beginSpan(llvm::StringRef Name, llvm::json::Object *Args) {
return Context::current().clone();
}
+
+void recordMemoryUsage(double Value, llvm::StringRef ComponentName) {
+ static constexpr Metric MemoryUsage("memory_usage", Metric::Value,
+ "component_name");
+
+ MemoryUsage.record(Value, ComponentName);
+}
} // namespace trace
} // namespace clangd
} // namespace clang
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88413.294686.patch
Type: text/x-patch
Size: 1386 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200928/2242fb14/attachment.bin>
More information about the cfe-commits
mailing list