[PATCH] D60609: Use native llvm JSON library for time profiler output

Sam McCall via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 16 13:07:09 PDT 2019


sammccall added a comment.

Just wanted to note I'm going to look at drafting a lower-level streaming output API so cases like this can avoid materializing all those expensive objects.

That said I don't claim any special expertise in this area, if someone else wants to jump on it, go ahead.



================
Comment at: llvm/lib/Support/TimeProfiler.cpp:91
 
-    OS << "{ \"traceEvents\": [\n";
+    json::Array Events;
 
----------------
Sorry, I was vaguely aware of this patch but hadn't looked at the detail.
As there's likely to be lots of events, I'd suggest still writing the `{"traceEvents":[` / `]}` container by hand and the "," separator between events if you care about performance.
You can still use the JSON lib for composing and serializing each individual event.
This is what we do in clangd.

This will reduce peak mem usage, but also the repeated allocation/deallocation of similar structures may make allocation cheaper (I know it does a lot with tcmalloc).

Not sure how much this will help, as always with performance, measuring is a good idea.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60609





More information about the llvm-commits mailing list