-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add profiling/performance docs #30
Comments
There's now a built-in profiling tool in Node.js (v4.4.0 or later) with support for Node/C++ addons that may be useful to document here in addition to tips on using the profiling tools in Instruments.app. |
Awesome suggestion @mikemorris, thank you! I took a look at Node's built-in profiler and have a couple general thoughts/noticings to consider for docs:
While running through some profiling in node-cpp-skel, it also became clear that the skel would benefit from some more benchmark variety in order to demonstrate some of the potential profiling scenarios. Currently, skel has a single iteration bench, also a batch bench that allows you to set concurrency (to mock threads) and the number of iterations. But the logic in shout() is pretty light, doesn't have any heavy logic that could provide valuable profiling info. So! Here are some ideas for beefing up the skel a bit to allow for more heavy-duty and informative profiling examples:
The idea is to have profiling examples documented for each of these scenarios. These docs would give a clear picture of what performance looks like when using a profiler. |
Capturing some knowledge from chat with @springmeyer... To properly bench multithreading:
What is
|
I believe it aggregates time spent across all threads in a single process. Multiple processes started by a single script each end up in separate log files named with the process ID.
I'm not sure if there's a way to get more fine-grained detail here, not seeing any mention of threads in the V8 Profiler docs.
Yep, I was specifically using this earlier this week to profile a Node.js/C++ app running on a Linux EC2. Your ideas for example functions to demonstrate different profiling scenarios sound 💯 |
Per chat with @mapsam and @mikemorris in #node-cpp channel today, quick recap of us attempting to fully understanding Two scenarios where threads are "waiting" for work:
Utilize @mapsam Noticed that even though his machine has 8 possible threads (in relation to # of cores), performance flatlined at 4 threads when benchmarking vt-shaver:
This launched us into discussion about why that is, and discovered that the threads were waiting for work 50% of the time ( Based on the two scenarios listed above, seems like the findings apply to Case # 1. But still curious about the flatlined graph and why performance maxed at 4 threads. @springmeyer @mikemorris any thoughts? Awesome post on threads in Node/C++ that is essentially what would be great to have for node-cpp-skel performance docs. |
Okay, this makes more sense. I think If performance flatlines at 4 threads and the CPU is maxed out at 400% (on a dual-core, hyperthreading machine where 4 virtual cores would be available), then that sounds like figure 2. If the CPU is under-utilized still when more threads are available, then that could be figure 3, indicating a bottleneck in the main loop somewhere, preventing work from being passed on to the threadpool. |
Capturing chat with @springmeyer:
Possible benchmark idea in node-cpp-skel
Realworld situation in api-glWe want to:
Step 1 is so fast that we do it sync rather than async (no libuv needed) to avoid the potential slowdown of interacting with the threadpool. |
Per chat with @springmeyer: The sleep scenario might not actually mimic anything you'd see in the realworld (since few apps actually sleep). So another possible bench scenario:
|
Thanks for capturing all of the conversation @GretaCB - great to follow along! |
@GretaCB okay if we close this? My recap would be:
In retrospec (and per #29 (comment)) the "scenarios" above I think are a bit too advanced for putting in node-cpp-skel directly. But rather things we could learn about and document as they come up in realworld scenarios as we use node-cpp-skel. |
@GretaCB Seeing anything more needed before closing? Looks like mapbox/cpp#43 finished moving some of the great graphics from here into formal docs 💯 |
Thanks for the followup @springmeyer . Yup, good to close. This ticket will be here for future reference, if needed. |
After some basic benchmarks are setup per #25, add documentation on how to profile. The batch bench test can be useful for this.
The text was updated successfully, but these errors were encountered: