Precompile bits/stdc++.h in the runner, and move it to clang-tidy 22
The first publish failed its smoke test: on the production host (2 slow cores) clang-tidy took over 30s on a two-line file and hit the runner's 20s lint limit, and even a trivial build took 4s, nearly all of it parsing <bits/stdc++.h>. The runner image now precompiles that header for g++ (.gch) and clang (.pch) with the flags the runner passes, and the runner uses them when they are there. g++ lint gains -O2 so the build's header matches it. Alpine 3.24's clang-tidy 22 walks far less of the system headers than 3.22's clang-tidy 20. Measured on the host: a build 3.9s to 0.6s, and clang-tidy 32.5s to 4.3s. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
+1
-1
@@ -178,7 +178,7 @@ The "Review my explanation" panel (admin only) takes a recording of the admin ex
|
||||
|
||||
- **The runner is its own service.** The site holds the Claude, Gitea and S3 secrets and shares `app-network` with the database, so it never runs code. `cmd/usacorunner` does, in a container with no environment, on an `internal` network that only the site joins, read-only apart from an exec-able `/tmp` tmpfs, with memory, CPU and pids limits, all capabilities dropped and tini as PID 1 to reap orphans. The site posts to it (`runner.Client`, `RUNNER_URL`); the browser never sees it.
|
||||
- **Runs copy the CLI.** The same g++ flags as `lib/common.sh` (`-DLOCAL`, with the repo root's `debugging.h` and `leetcode.h`, and a LeetCode problem's `driver.h`, sent along), the program runs in a directory holding `<io>.in` with that file also on stdin, `<io>.out` is its output if it wrote one, and outputs compare as `usaco test` does, ignoring trailing whitespace and trailing blank lines. Unlike the CLI there are limits: CPU time (2 s by default; TLE), 512 MB of address space, 64 MB files, a wall clock, and 60 s for a whole request, which keeps it synchronous under nginx's 120 s.
|
||||
- **Lint.** C++ is g++'s warnings plus clang-tidy with the repo's `.clang-tidy` (bugprone, performance and a few readability checks, tuned so `template.cpp` is clean); the runner embeds a copy, and a test keeps the two equal. Python is `compile()` for syntax errors plus ruff (`E4,E7,E9,F,B`). A missing tool is skipped.
|
||||
- **Lint.** C++ is g++'s warnings plus clang-tidy with the repo's `.clang-tidy` (bugprone, performance and a few readability checks, tuned so `template.cpp` is clean); the runner embeds a copy, and a test keeps the two equal. Python is `compile()` for syntax errors plus ruff (`E4,E7,E9,F,B`). A missing tool is skipped. The runner image precompiles `bits/stdc++.h` for g++ and clang-tidy (`internal/runner/pch.go`), which on the production host takes a build from about 4 s to 0.6 s and a clang-tidy pass from over 30 s to about 4 s (with Alpine 3.24's clang-tidy 22).
|
||||
|
||||
## Things that are easy to get wrong
|
||||
|
||||
|
||||
Reference in New Issue
Block a user