[PATCH] D88413: [clangd] Add a metric for tracking memory usage
Kadir Cetinkaya via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 5 01:54:15 PDT 2020
kadircet updated this revision to Diff 296112.
kadircet added a comment.
- Rebase
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D88413/new/
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.296112.patch
Type: text/x-patch
Size: 1386 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201005/32ee60f2/attachment.bin>
More information about the cfe-commits
mailing list