Debugging performance issues

This topic is for advanced users only. If you find yourself debugging a performance issue like a memory leak, you need to know your way around the Go language.

Geopoiesis web server comes with a /pprof endpoint, which developers can use to debug Go. This endpoint uses the runtime/pprof library, so it should be compatible with the standard Go profiling toolchain. However, because the endpoint is exposed remotely, it requires authentication and so the URL structure is slightly different - $proto://$host/pprof?name=$profile&jwt=$jwt, where:

  • $proto is the protocol used - normally just http or https;

  • $host is the name of the host - for example;

  • $profile is the name of the profile to display - see the list of predefined profiles here;

  • $jwt is base64-encoded Geopoiesis access token - it's available either through the GraphQL API by accessing the jwt field of the oauthUser query, or - if you're using the GUI - you can find it in your browser's local storage;

Finding token in the GUI

In order to find your access token through the GUI, please open the browser developer console, and inspect local storage:

You can encode that value using base64 by echoing that value and piping it to base64 command-line utility:

$ echo mysecrettoken | base64

Note that Geopoiesis user access tokens are short-lived and will only be valid for an hour. If a token expires, the server will respond with status code 401.

Using pprof

When you have the encoded token ready, you can run go tool pprof to get performance data for your app. As an example, let's look at our heap (note that in order to make a pretty picture, you'll need to have Graphviz installed on your local machine):

$ go tool pprof -png '' > heap.png
Saved profile in /Users/marcinwyszynski/pprof/pprof.geopoiesis.alloc_objects.alloc_space.inuse_objects.inuse_space.006.pb.gz

And here it is:

For better readability, .svg or .pdf formats should probably be used.