- Go 75.4%
- Makefile 17.6%
- Nix 7%
| broadcast | ||
| echo | ||
| unique-ids | ||
| .envrc | ||
| .gitignore | ||
| .golangci.yml | ||
| flake.lock | ||
| flake.nix | ||
| go.mod | ||
| go.sum | ||
| Makefile | ||
| publish.yaml | ||
| README.md | ||
Gossip Glomers
Solutions to the Gossip Glomers distributed systems challenges.
Setup
The toolchain (Go, Maelstrom, graphviz, gnuplot) comes from the flake's dev shell, so the only prerequisite is Nix with flakes enabled. If you don't have it, the Determinate Systems installer sets up Nix with flakes on macOS and Linux:
curl -fsSL https://install.determinate.systems/nix | sh -s -- install
If you use the official installer instead, enable
flakes by adding experimental-features = nix-command flakes to
~/.config/nix/nix.conf.
Then enter the dev shell:
nix develop
Or, with direnv installed and
hooked into your shell, run this once and
the shell loads automatically whenever you cd into the repo:
direnv allow
Binaries are installed into ./bin (the Makefile and .envrc both set GOBIN).
Running a challenge
Each challenge is a main package in its own directory, all in one Go module.
Run from the repo root:
make echo # build bin/echo and run the Maelstrom echo test
make unique-ids # build bin/unique-ids and run the unique-ids test
make build # build every challenge
make serve # browse results in ./store at http://127.0.0.1:8080
To add a challenge, create <name>/main.go and add a Makefile target with its
maelstrom test flags. List the target in .PHONY, because it usually shares a
name with the challenge's directory and make would otherwise call it up to date.
Checks
Set up from go/template. The root pre-commit hook runs
make fmt lint test on the working tree, so an unfinished challenge blocks
every commit here until its tests pass.
| command | what it does |
|---|---|
make test |
test with the race detector in random order; fail under 75% coverage |
make lint |
check go mod tidy, golangci-lint and alejandra, changing nothing |
make fmt |
tidy modules and format with gofumpt, goimports and alejandra |
make audit |
govulncheck, then fuzz each Fuzz* target, then benchmarks |
make clean |
remove bin/, coverage and the test and fuzz caches |
make update |
update flake.lock to the latest nixpkgs-26.05 |
The floor is 75% rather than the template's 80% because each challenge's
main() starts a real Maelstrom node and goes untested.
Broadcast worklog
At C
almost worst case
- when n = 25
- estimate: ~2 * sqrt(25) = 10 * latency (100) = 1000ms
- in actuality: 4 horizontal + 4 vertical hops = 800ms assume clients are colocated
other cases
- topology: grid (default), line, total, tree, tree2, tree3, tree4
- latency-dist: constant (default), uniform, exponential
best case
- every node is connected
-
messages = n-1
- no ack needed (?)
messages: 78 per op
latency: median 456ms, max 817ms
After removing sender from broadcast list
messages: 59.2 per op
latency: median 457ms, max 814ms