N|Solid Documentation


CPU Profiling

CPU profiling allows you to understand where opportunities exist to improve the speed and load capacity of your node process. N|Solid provides multiple ways to profile your CPU.

Analyzing Profiles Using the N|Solid Console

The N|Solid Console allows you to take and analyze profiles in one action. This is particularly useful if you need to take a series of profiles as it saves you the overhead of switching from one environment to another. The console also saves a history of profiles so you can quickly flip through profiles to identify troublesome areas.

  1. Launch the console and select the application of interest "All applications"
  2. Select the process of interest "Select process"
  3. Expand out the details panel and select ‘+ New Profile’
    "New profile"
  4. Select your profile window (5 to 60 seconds) and run profile "Run profile"
  5. Select a visualization (Sunburst, Flamegraph or Treemap). Once a visualization is selected, you can click on it to view the call stack to the right. The number of calls to that method are shown as are the time spent within it. Clicking on the method will show you the file responsible for that call. "Call stack"
  6. Profiles are saved in your console session so you can easily flip between profiles.

Profiling using the Command Line Interface (CLI)

N|Solid's Command Line Interface (CLI) is a great way to quickly pull profiles from remote processes for local examination. With NSolid installed and on your path, a pair of commands are used to accomplish this.

profile_[start, stop]


nsolid-cli -- socket XXXX profile_start

nsolid-cli -- socket XXXX profile_stop > my.cpuprofile

Collection will commence immediately after ‘profile_start’ hits the wire and will continue for up to 60 seconds. If profile_stop is not entered before 60 seconds then the process times out and the profile data is discarded. Order of execution is always profile_start, then profile_stop.

Looking to do a timed test?

You can do this with some simple scripting!

nsolid-cli --socket 5000 profile_start\n
ab -n 1000 -c 100 http://localhost:8000\n
nsolid-cli --socket 5000 profile_stop > 1.cpuprofile

This will do a CPU profile while running a load test with ab (Apache Bench). If you wanted to do a timed one, replace the ab invocation with sleep 10 (to sleep for 10 seconds)."

Once the .cpuprofile file has been created, it can be opened using Chrome’s Development Tool’s CPU Profile Debugging Tool. It’s important to note that Chrome requires the generated file to have the extension .cpuprofile so be sure to use that.

Profiling explained

Learn how profiling can help build a better product.

Need Help Installing the Console?

Read our Console Installation Guide.