[PATCH] D39086: Performance tracing facility for clangd.
Sam McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 19 02:19:34 PDT 2017
sammccall created this revision.
Herald added a subscriber: mgorny.
This lets you visualize clangd's activity on different threads over time,
and understand critical paths of requests and object lifetimes.
The data produced can be visualized in Chrome (at chrome://tracing), or
in a standalone copy of catapult (http://github.com/catapult-project/catapult)
This patch consists of:
- a command line flag "-trace" that causes clangd to emit JSON trace data
- an API (in Trace.h) allowing clangd code to easily add events to the stream
- several initial uses of this API to capture JSON-RPC requests, builds, logs
Example result: https://photos.app.goo.gl/12L9swaz5REGQ1rm1
Caveats:
- JSON serialization is ad-hoc (isn't it everywhere?) so the API is limited to naming events rather than attaching arbitrary metadata. I'd like to fix this (I think we could use a JSON-object abstraction).
- The recording is very naive: events are written immediately by locking a mutex. Contention on the mutex might disturb performance.
- For now it just traces instants or spans on the current thread. There are other things that make sense to show (cross-thread flows, non-thread resources such as ASTs). But we have to start somewhere.
https://reviews.llvm.org/D39086
Files:
clangd/CMakeLists.txt
clangd/ClangdServer.cpp
clangd/ClangdUnit.cpp
clangd/JSONRPCDispatcher.cpp
clangd/ProtocolHandlers.cpp
clangd/Trace.cpp
clangd/Trace.h
clangd/tool/ClangdMain.cpp
test/clangd/trace.test
unittests/clangd/CMakeLists.txt
unittests/clangd/TraceTests.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39086.119559.patch
Type: text/x-patch
Size: 19090 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171019/d6c9082b/attachment-0001.bin>
More information about the cfe-commits
mailing list