Skip to content

Latest commit

 

History

History
59 lines (38 loc) · 1.92 KB

PROFILING.md

File metadata and controls

59 lines (38 loc) · 1.92 KB

Profiling

This guide is not meant to replace any official documentation, but rather to provide a quick overview of the steps required to profile the node.

Profiling endpoint feature flag

We pre-configured the node to expose a web server on port 6060 for the collection of profiling data.

Because of the performance overhead, it is disabled by default. In order to enable it, you can simply add the environment variable PPROF_ENABLED=true to the node.

You can do that in several ways, the most obvious spot would be the docker-compose.yml file, in the environment section of the validator1 service.

environment:
# Uncomment to enable the pprof server
#  - PPROF_ENABLED=true

Example

Let's assume that you want to profile the memory usage of the node during the execution of the ResetToGenesis command.

These are the necessary steps:

  1. Enable the pprof server in the docker-compose.yml file (see above)
  2. Collect a "baseline" heap profile of the node by running the following command:
curl http://localhost:6060/debug/pprof/heap > baseline.heap
  1. Run the ResetToGenesis command from the debug CLI
  2. Collect another heap profile of the node by running the following command:
curl http://localhost:6060/debug/pprof/heap > after_reset.heap
  1. Compare the two profiles using the pprof tool:
go tool pprof -base=baseline.heap after_reset.heap
  1. From the pprof prompt, you can run the top command to see the top 10 (can be any number) memory consumers:
(pprof) top10
  1. By repeating the steps above, and comparing different heap profiles, you can identify the memory consumers that are causing the memory usage to grow. It could be a memory leak, or just a normal behavior.

Further reading