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 measuring section to performance #562

Merged
merged 1 commit into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
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
23 changes: 23 additions & 0 deletions building/tooling/best-practices.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,29 @@ The official [Dockerfile best practices](https://docs.docker.com/develop/develop
You should primarily optimize for performance (especially for test runners).
This will ensure your tooling runs as fast as possible and does not time-out.

### Measure

Measuring execution time often is a great way to get a feel for the performance of tooling.
Make it a habit to measure execution time both after _and_ before a change.
Even when you feel "certain" that a change will improve performance, you should still measure execution time.

#### Scripts

When possible, create scripts to automatically measure performance (also known as _benchmarking_).
A very helpful command-line tool is [hyperfine](https://github.com/sharkdp/hyperfine), but feel free to use whatever makes the most sense for your tooling.

Newer track tooling repos will have access to the following two scripts:

1. `./bin/benchmark.sh`: benchmark the track tooling code ([source code](https://github.com/exercism/generic-test-runner/blob/a6886f4d84d2a2030f766a658c334bbfbe97b79c/bin/benchmark.sh))
2. `./bin/benchmark-in-docker.sh`: benchmark the track tooling Docker image ([source code](https://github.com/exercism/generic-test-runner/blob/a6886f4d84d2a2030f766a658c334bbfbe97b79c/bin/benchmark-in-docker.sh))

If you're working on a track tooling repo without these files, feel free to copy them into your repo.

```exercism/caution
Benchmarking scripts can help estimate the tooling's performance.
Bear in mind though that the performance on Exercism's production servers is often lower.
```

### Experiment with different Base images

Try experimenting with different base images (e.g. Alpine instead of Ubuntu), to see if one (significantly) outperforms the other.
Expand Down
3 changes: 2 additions & 1 deletion building/tooling/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ Our [Best Practices page](/docs/building/tooling/best-practices) has lots of tip
The test runner gets 100% CPU with 3GB of memory for a 20 second window per solution.
After 20 seconds, the process is halted and reports a time-out with a 408 error code.

We highly recommend following our [Performance Best Practices document](/docs/building/tooling/best-practices#h-performance) to reduce the chance of timeout occuring.

### Stdout/stderr

A tooling run may produce up to a maximum of one-megabyte of stdout and stderr.
Expand All @@ -35,7 +37,6 @@ If the file is larger than this, the tooling run will be killed with a 460 error
## Configuration

Each solution gets 100% machine resources for a twenty second window.

After 20 seconds, the process is halted and reports as a time-out.

Some tools require (slight) deviations from the default configuration.
Expand Down