Could you please recommend a C++ performance profiler for Windows 64-bit that can attach to a running process and collect stack traces? The profiled program is massively-multithreaded: thousands of threads that are mostly waiting for network activity. Some tools do not work with my program because my program throws exceptions.

  • Which profiler has problems with exceptions? A profiler should not be interested in exceptions at all. – Thomas Weller Jul 2 '20 at 19:12
  • Why are 1000 threads waiting? Isn't that quite useless? And - if they are waiting, what should the profiler tell you other than they are waiting? Do 1000 threads make sense on a 16 core machine? – Thomas Weller Jul 2 '20 at 19:16
  • @ThomasWeller, it's softwareverify.com/performance-profiling.php that can't profile programs that throw exceptions. As to multithreading, I tried VTune, MSVS 2019 built-in profiler, VerySleepy and many more - they all can't handle 11K threads. Yes, these threads are waiting, but they are waiting in a library out of my control. The library however has an interface that doesn't require 1 thread per connection, but it is very complicated. The profiler should give me insights about the threads that are not waiting. – Serge Rogatch Jul 2 '20 at 20:39

Since you do not have many requirements, I suggest starting with Windows Performance Toolkit (WPT). WPT is not available as a standalone tool. It is part of the Windows Assessment and Deployment Kit (WADK).

WPT is not a single tool. It's made of two parts: Windows Performance Recorder (WPR) and Windows Performance Analyzer (WPA).

By default, the recorder (WPR) will capture the activity of the whole system (that's ~2800 threads here currently) without any issues.

And here's an example of what a stack analysis looks like for the Windows Compatibility Telemetry process, done with WPA after recording:

Example of WPA

The blue highlighting in the CPU graph corresponds to the selection of MSXML6 calling SchemaCache::validate(). You can see how many times it was called and how many milliseconds were spent there.

Windows Performance Toolkit

  • is made by Microsoft and works on Windows
  • can analyze C++ or any language that compiles to x86 code. It's not so good for stuff that compiles to intermediate languages (IL) such as C# or Java.
  • is gratis (free of cost, but not open source)
  • is capable of analyzing 2000+ threads
  • does not care about exceptions in your program (when your program crashes, you'll still have the data up to that point)
  • Unfortunately, Windows Performance Recorder produces a 320GB file, and then Windows Performance Analyzer fails to load it, complaining about running out of storage (1.5TB free space before running WPA). – Serge Rogatch Jul 3 '20 at 6:07
  • How long are you recording? @SergeRogatch – Thomas Weller Jul 3 '20 at 8:05
  • About 15 minutes. – Serge Rogatch Jul 3 '20 at 8:06
  • @SergeRogatch: I think I will delete this answer. Would it be ok for you to integrate all the comments into your question? I think you'll get better responses when we know more requirements / have a better understanding what you already tried. – Thomas Weller Jul 3 '20 at 8:48
  • I think your answer may be fine for someone else, and I've already upvoted it :) . – Serge Rogatch Jul 3 '20 at 9:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.