Skip to content

Latest commit

 

History

History
50 lines (32 loc) · 1.29 KB

PROFILING.md

File metadata and controls

50 lines (32 loc) · 1.29 KB

Profiling

Ensure the policy-server is running with the --enable-pprof flag. This can also be set with the KUBEWARDEN_ENABLE_PPROF=1 environment variable.

Note: the memory profiling will cause a slightly higher CPU usage. We could fix that by activating the memory profiling only after the first dump is requested. Open a GitHub issue if you think this is a good idea.

CPU

  1. Port-forward policy-server port (8443):
kubectl port-forward -n kubewarden service/policy-server-default 8443:8443
  1. Download the CPU profile using curl:
curl --insecure https://localhost:8443/debug/pprof/cpu -o cpu_profile.prof
  1. Use pprof to analyze the profile:
pprof -http=:8080 cpu_profile.prof

Memory

To obtain a memory profile:

  1. Port-forward policy-server port (8443):
kubectl port-forward -n kubewarden service/policy-server-default 8443:8443
  1. Download the CPU profile using curl:
curl --insecure https://localhost:8443/debug/pprof/heap -o heap_profile.prof
  1. Use pprof to analyze the profile:
pprof -http=:8080 heap_profile.prof

Warning: do not use the pprof tool from the go tool binary, it cannot handle the memory profile generated by Policy Server.