exercism / exercism/julia

Multi-threading - should we enable it?

Open
#1,019 2 comments 1 reaction 0 assignees View on GitHub
Dominant language
Julia
Stars
73
Forks
82
Avg merge
2h 17m
Merged PRs (30d)
5

Description

Currently, the Julia test-runner starts Julia from a small [shell script](https://github.com/exercism/julia-test-runner/blob/main/run.sh) with the line

```bash
julia --project --sysimage test-runner-sysimage.so run.jl "$1" "$2" "$3"
```

This starts Julia with the default single thread: `Threads.nthreads()` returns 1 if you abuse the online editor by embedding this in a return string ("Hello World!" lends itself to this, with the number embedded in an error message).

I'm starting to think (with some trepidation!) about how we add the two main practice exercises using multi-threading:
- `bank-account` needs to send tests in parallel, and student solutions need to handle this and avoid race conditions.
- `parallel-letter-frequency` needs the student to parallelize code, with a scatter-gather strategy across multiple threads.

To deal with this, we could change the start of the above line of code to either `julia --threads auto` or something like `julia --threads 4`.

Should we?

I haven't yet tried a test build of the docker image with this sort of change. On my Linux box, starting with `--threads auto` then running `Threads.nthreads()` returns 16 (for a Ryzen 7 CPU, 8 physical cores dual-pipelined).

I have no idea how many threads will auto-start on the AWS system running our docker image in production. We could maybe try it, and if we end up with a crazy huge number we could back off to 4 or 8.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.