This guide documents build performance characteristics and optimization strategies for ResearchProcess-GPS, particularly focusing on the module system which has the heaviest dependencies.
The ResearchProcess-GPS project includes several heavy dependencies that significantly impact build times:
-
Wasmtime (25.0)
- Full WebAssembly runtime
- Cranelift JIT compiler
- ~100+ transitive dependencies
-
SQLx
- Compile-time checked SQL
- PostgreSQL driver
- Async runtime integration
-
Cryptographic Libraries
- ring (crypto primitives)
- rustls (TLS implementation)
- Various hash/signature libraries
-
Unicode/Internationalization
- ICU libraries
- Unicode normalization
- Locale support
| Build Type | Clean Build | Incremental | Notes |
|---|---|---|---|
cargo check |
30-60s | 5-10s | Type checking only |
cargo build |
3-5 min | 15-30s | Debug build |
cargo build --release |
5-10 min | 30-60s | Optimized build |
cargo test --no-run |
5-10 min | 20-40s | Compile tests |
| Full test suite | 10-15 min | 1-2 min | Compile + run |
Times measured on 8-core VM with 16GB RAM
# Limit parallel jobs on constrained systems
export CARGO_BUILD_JOBS=2 # Adjust based on available cores
# Disable incremental compilation if having issues
export CARGO_INCREMENTAL=0
# Use faster linker (if available)
export RUSTFLAGS="-C link-arg=-fuse-ld=lld"Already configured in workspace Cargo.toml:
[profile.dev]
opt-level = 0
debug = 1
split-debuginfo = "unpacked"
incremental = false
[profile.test]
opt-level = 1
debug = 1
incremental = false
[profile.release]
opt-level = "z"
lto = false # Disabled to reduce memory usage
codegen-units = 16For resource-constrained environments:
# Step 1: Build dependencies only
cargo build --package rp-modules --lib
# Step 2: Build tests separately
cargo test --package rp-modules --no-run
# Step 3: Run tests
cargo test --package rp-modules# Install sccache for build caching
cargo install sccache
# Configure
export RUSTC_WRAPPER=sccache
export SCCACHE_DIR=~/.cache/sccache
export SCCACHE_CACHE_SIZE="10G"# Install cargo-cache
cargo install cargo-cache
# Clean old artifacts
cargo cache -a # Show cache info
cargo cache -r all # Clean everything
cargo cache -r registry-sources # Clean source archivesWhen building over X11 forwarding (e.g., NoMachine, VNC):
-
High Xorg CPU Usage
- Normal when terminal shows build output
- NOT indicative of actual system stress
- Consider redirecting output:
cargo build > build.log 2>&1
-
Mitigation Strategies
# Build with minimal output cargo build --quiet # Or use a multiplexer tmux new-session -d 'cargo build' tmux attach
- Resources scale dynamically
- Don't judge by momentary spikes
- Swap usage is normal for large builds
- Consider build containers with resource limits
Reality: Likely just slow compilation
Solutions:
- Check
ps aux | grep cargofor activity - Monitor
~/.cargodirectory for file changes - Use
cargo build -vvfor detailed output - Extend timeouts in CI/CD
Solutions:
- Reduce parallel jobs:
CARGO_BUILD_JOBS=1 - Disable LTO in release builds
- Increase swap space temporarily
- Use
cargo checkinstead of full builds
Reality: Terminal rendering overhead
Solutions:
- Build in tmux/screen session
- Redirect output to file
- Use SSH instead of GUI forwarding
- Build with
--quietflag
# Time your builds
time cargo build --package rp-modules
# Use cargo's built-in timings
cargo build --timings
# Opens HTML report showing bottlenecks# Monitor during build
watch -n 1 'free -h; echo; ps aux | grep cargo | grep -v grep'
# Or use htop in another terminal
htop -d 10-
Use cargo check frequently
- Catches most errors
- 10x faster than full build
- Run before commits
-
Incremental Testing
# Test only what changed cargo test --package rp-modules specific_test_name
-
Feature Flags
# Build without WASM when not needed cargo build --no-default-features
-
Cache Configuration
cache: key: ${CI_COMMIT_REF_SLUG} paths: - target/ - ~/.cargo/registry/ - ~/.cargo/git/
-
Timeout Settings
build: timeout: 20 minutes # Generous for first builds
-
Parallel Jobs
variables: CARGO_BUILD_JOBS: "4" # Adjust for CI runner
Last Updated: 2025-08-01
ResearchProcess-GPS Development Team