Rocq worker processes can consume excessive system resources (memory, CPU, disk IO), making the system unresponsive during proof compilation.
Use systemd-run with cgroups v2 resource controls to limit resource usage.
systemd-run --user --scope \
-p MemoryMax=150G \
-p CPUQuota=2700% \
-p IOWeight=50 \
-p TasksMax=300 \
make -j4
Parameters Explained:
--user: Run in user session (no sudo required)--scope: Run synchronously (see output directly)-p MemoryMax=150G: Hard limit of 150GB RAM (~60% of 252GB)-p CPUQuota=2700%: Limit to 27 cores (75% of 36 cores; 100% = 1 core in systemd)-p IOWeight=50: Lower IO priority to reduce disk thrashing-p TasksMax=300: Limit total number of processes/threadsmake -j4: Run 4 parallel compilation jobsImportant: Understanding -j vs CPUQuota:
-j4: Controls how many make targets (files) compile simultaneouslyCPUQuota=2700%: Controls total CPU resources available (27 cores)-j4 and 27 cores: each job gets ~6-7 cores on average-j equal to CPU cores! Each job needs multiple cores for internal parallelism-j4 to -j8 for optimal memory/CPU balance (each job may use 10-20GB RAM)-j ValueRule of thumb: Set -j to 10-25% of available CPU cores, not equal to cores.
| CPU Cores | CPUQuota | Recommended -j | Reasoning |
|---|---|---|---|
| 36 cores | 2700% (27 cores) | -j4 to -j8 | Each job gets 3-7 cores for internal workers |
| 24 cores | 1800% (18 cores) | -j3 to -j6 | Balanced parallelism |
| 16 cores | 1200% (12 cores) | -j2 to -j4 | Prevents memory exhaustion |
| 8 cores | 600% (6 cores) | -j2 | Single file compilation may use 3 cores |
Why not -j27 with 27 cores?
Experimentation:
-j4, monitor with htop-j6 or -j8-j2 or -j3Use if system still feels sluggish:
systemd-run --user --scope \
-p MemoryMax=100G \
-p CPUQuota=1800% \
-p IOWeight=30 \
-p TasksMax=200 \
make -j2
Use if you want faster builds and can tolerate some system slowdown:
systemd-run --user --scope \
-p MemoryMax=200G \
-p CPUQuota=3200% \
-p IOWeight=100 \
-p TasksMax=500 \
make -j8
When you need to see errors clearly without parallel compilation:
systemd-run --user --scope \
-p MemoryMax=100G \
-p CPUQuota=900% \
-p IOWeight=30 \
make -j1
cd /home/dylon/Workspace/f1r3fly.io/liblevenshtein-rust/docs/verification/phonetic
# Clean and rebuild everything
systemd-run --user --scope \
-p MemoryMax=150G \
-p CPUQuota=2700% \
-p IOWeight=50 \
-p TasksMax=300 \
bash -c "make clean && make -j4 2>&1 | tee /tmp/coq_build.log"
systemd-run --user --scope \
-p MemoryMax=150G \
-p CPUQuota=2700% \
-p IOWeight=50 \
-p TasksMax=300 \
make theories/Patterns/PatternOverlap.vo
# Watch memory and CPU of rocq processes
watch -n 2 'ps aux | grep -E "rocq|coq" | grep -v grep'
# Or use htop filtered to rocq processes
htop -p $(pgrep -d',' rocq)
# Show resource usage of the running scope
systemctl --user status run-*.scope
# Show detailed cgroup statistics
systemd-cgtop --user
If the system becomes unresponsive despite limits:
# Kill all rocq/coq processes
pkill -9 rocq
pkill -9 coq
pkill -9 make
# Or kill the systemd scope
systemctl --user stop run-*.scope
# Or kill all user processes in the cgroup
systemctl --user kill run-*.scope
systemd-run --user works without root privilegestee to capture output to a log file for debugging# Check if systemd user session is running
systemctl --user status
# If not running, start it
systemctl --user start
Increase MemoryMax:
systemd-run --user --scope -p MemoryMax=200G -p CPUQuota=2700% -p IOWeight=50 make -j4
Increase CPUQuota and parallel jobs:
systemd-run --user --scope -p MemoryMax=150G -p CPUQuota=3200% -p IOWeight=100 make -j8
Command used for successful compilation (2025-11-20):
systemd-run --user --scope \
-p MemoryMax=150G \
-p CPUQuota=2700% \
-p IOWeight=50 \
-p TasksMax=300 \
make -j4 2>&1 | tee /tmp/compile_j4_limited.log
This configuration successfully compiled all 9 Coq modules without system unresponsiveness.
Can you improve this documentation?Edit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |