Skip to content
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 section on profiling synse server #23

Merged
merged 1 commit into from
Apr 15, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions docs/server/developer/debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,45 @@ stdout/stderr, so they can be accessed via `docker logs`, e.g.
```
docker logs synse-server
```

## Profiling

As of Synse Server version `v3.0.1`, a `--profile` flag is made available to run Synse Server in
profiling mode. This uses [cProfile](https://docs.python.org/3/library/profile.html#module-cProfile)
to gather the profiling data. When the flag is set, profiling data will be printed out to console and
written out to file (synse-server.profile).

To set the flag, pass `--profile` in as a command to the container, e.g.

```
docker run vaporio/synse-server --profile
```

or, in a compose file

```yaml
version: '3'
services:
synse-server:
image: vaporio/synse-server
ports:
- '5000:5000'
command: ['--profile']
```

To get the profiling data, stop synse server (e.g. `docker stop synse-server`). You can view the
profiling data by:

- looking at the container logs (`docker logs synse-server`)
- copying the profile out of the container (`docker cp synse-server:/synse/synse-server.profile .`)

From there, you can use tools like [`gprof2dot`](https://github.com/jrfonseca/gprof2dot) and
[`dot`](https://github.com/pydot/pydot) to create graphs of the data, or write a simple script
to parse the profiling data as desired.

For example:

```bash
$ gprof2dot -f pstats synse-server.profile -o synse-server.dot
$ dot -Tpng synse-server.dot -o synse-server.png
```