{"id":46082503,"url":"https://github.com/tensorturtle/distributed-cpu-stress-reporter","last_synced_at":"2026-03-01T16:02:16.567Z","repository":{"id":322247988,"uuid":"1088607657","full_name":"tensorturtle/distributed-cpu-stress-reporter","owner":"tensorturtle","description":"Simple CPU stress test server that loads up all CPUs and reports the current processing power via HTTP. Created for Yundera internal Proxmox experiments.","archived":false,"fork":false,"pushed_at":"2025-11-18T12:44:39.000Z","size":112,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-12-02T04:04:29.972Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tensorturtle.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-11-03T07:55:34.000Z","updated_at":"2025-11-18T12:40:03.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/tensorturtle/distributed-cpu-stress-reporter","commit_stats":null,"previous_names":["tensorturtle/distributed-cpu-stress-reporter"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/tensorturtle/distributed-cpu-stress-reporter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tensorturtle%2Fdistributed-cpu-stress-reporter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tensorturtle%2Fdistributed-cpu-stress-reporter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tensorturtle%2Fdistributed-cpu-stress-reporter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tensorturtle%2Fdistributed-cpu-stress-reporter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tensorturtle","download_url":"https://codeload.github.com/tensorturtle/distributed-cpu-stress-reporter/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tensorturtle%2Fdistributed-cpu-stress-reporter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29974321,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-01T15:41:30.362Z","status":"ssl_error","status_checked_at":"2026-03-01T15:37:07.343Z","response_time":124,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-03-01T16:02:15.964Z","updated_at":"2026-03-01T16:02:16.555Z","avatar_url":"https://github.com/tensorturtle.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Distributed CPU Stress Reporter\n\nLightweight HTTP server that stress-tests CPU cores and reports performance metrics. Built for measuring CPU performance in virtualized environments.\n\n## Quick Start\n\n```bash\ngit clone https://github.com/tensorturtle/distributed-cpu-stress-reporter.git\ncd distributed-cpu-stress-reporter\ncargo build --release\n./target/release/distributed-cpu-stress-reporter\n```\n\nStart CPU stress test and query performance:\n```bash\n# Start the CPU stress test (requires mode specification)\ncurl -X POST http://localhost:8080/start-cpu \\\n  -H 'Content-Type: application/json' \\\n  -d '{\"mode\":\"fresh-process\"}'\n\n# Query performance\ncurl http://localhost:8080/cpu-perf\n# Returns: 254060 (operations/second)\n\n# Stop the CPU stress test\ncurl -X POST http://localhost:8080/end-cpu\n```\n\n## Use Case\n\nTest CPU overprovisioning in VMs. Run this in multiple VMs on the same hypervisor to see how CPU contention affects actual performance.\n\n**Example:** Proxmox host with 8 cores running 4 VMs with 4 vCPUs each (2x overprovisioned):\n\n```bash\n# Start CPU stress test on all VMs\nfor vm in vm1 vm2 vm3 vm4; do\n  curl -X POST http://$vm:8080/start-cpu \\\n    -H 'Content-Type: application/json' \\\n    -d '{\"mode\":\"fresh-process\"}'\ndone\n\n# Query each VM\ncurl http://vm1:8080/cpu-perf  # 240000 ops/sec\ncurl http://vm2:8080/cpu-perf  # 238000 ops/sec\ncurl http://vm3:8080/cpu-perf  # 120000 ops/sec  ← throttled!\ncurl http://vm4:8080/cpu-perf  # 241000 ops/sec\n```\n\n**Deploy to multiple VMs:**\n```bash\n# On each VM, run:\ncurl -L https://files.tensorturtle.com/yundera-cpu-stress/cpu-stress-linux-amd64 -o cpu-stress \u0026\u0026 chmod +x cpu-stress \u0026\u0026 ./cpu-stress\n```\n\n**Monitor multiple VMs:**\n```bash\n# Start CPU stress on all VMs\nfor vm in 192.168.1.{101..104}; do\n  curl -s -X POST http://$vm:8080/start-cpu \\\n    -H 'Content-Type: application/json' \\\n    -d '{\"mode\":\"fresh-process\"}'\ndone\n\n# Monitor performance\nwhile true; do\n  for vm in 192.168.1.{101..104}; do\n    echo \"$vm: $(curl -s http://$vm:8080/cpu-perf) ops/sec\"\n  done\n  sleep 2\ndone\n```\n\n## How It Works\n\n- Spawns threaded workers, fresh-process spawners, and burst coordinator (one per CPU core)\n- CPU stress test starts in STOPPED state (use `/start-cpu` to begin)\n- Mode selection determines which worker type is active:\n  - **Threaded mode**: Long-running threads continuously calculate primes (max performance)\n  - **Fresh-process mode**: Spawns short-lived child processes for each calculation cycle (avoids scheduler bias)\n  - **Bursty mode**: Spawns processes during bursts with exponential distribution timing (realistic workload patterns)\n- Atomic counters track operations per second with time-aware metrics for bursty mode\n- HTTP server (Axum) provides control and query endpoints:\n  - POST `/start-cpu` - Start CPU stress test (requires JSON body with mode and optional utilization)\n  - POST `/end-cpu` - Stop CPU stress test\n  - GET `/cpu-perf` - Get current operations per second (threaded/fresh-process modes)\n  - GET `/burst-perf` - Get burst-only operations per second (bursty mode)\n\n**Why prime numbers?** Pure CPU computation with no I/O - perfect for measuring CPU performance.\n\n## Scheduler Catch-Up Bias\n\nWhen running multiple instances of this program competing for limited CPU cores, you may observe that **newly launched instances receive more CPU allocation** than older running instances. This is a Linux scheduler behavior called \"catch-up bias.\"\n\n**What happens:**\n- The Linux CFS (Completely Fair Scheduler) tracks CPU time consumed by each process (virtual runtime)\n- Older processes have accumulated more virtual runtime\n- Newly launched processes start with low virtual runtime\n- The scheduler prioritizes processes that are \"behind\" to achieve fairness\n- Result: New instances temporarily get more CPU to \"catch up\"\n\n**Why this matters for testing:**\nWhen measuring CPU overprovisioning effects, catch-up bias can skew results. If you launch instances at different times, newer instances will appear to perform better, making it difficult to measure true steady-state CPU contention.\n\n**Solutions:**\n\n1. **Launch all instances simultaneously** - Start all test instances at the same time to ensure fair comparison\n2. **Wait for equilibrium** - Let instances run for several minutes until scheduler balancing stabilizes\n3. **Use fresh-process mode** (recommended, see below)\n\n### Execution Modes\n\nThe application supports three execution modes, controlled via the HTTP API:\n\n#### Fresh Process Mode (Default \u0026 Recommended)\n\n```bash\ncurl -X POST http://localhost:8080/start-cpu \\\n  -H 'Content-Type: application/json' \\\n  -d '{\"mode\":\"fresh-process\"}'\n```\n\nIn this mode:\n- Main HTTP server runs continuously\n- Each CPU calculation runs in a fresh child process that exits after completing work\n- No long-running processes accumulate virtual runtime\n- All instances get equal scheduler treatment regardless of start time\n\n**When to use:**\n- Testing multiple instances launched at different times\n- Measuring steady-state CPU contention without scheduler bias (recommended)\n- Comparing performance across instances that need equal scheduler treatment\n\n#### Threaded Mode\n\n```bash\ncurl -X POST http://localhost:8080/start-cpu \\\n  -H 'Content-Type: application/json' \\\n  -d '{\"mode\":\"threaded\"}'\n```\n\nIn this mode:\n- Long-running worker threads continuously calculate primes\n- Maximum CPU stress and absolute performance\n- Subject to scheduler catch-up bias when multiple instances compete\n\n**When to use:**\n- Maximum CPU stress and performance\n- Single instance testing\n- All instances launched simultaneously\n\n#### Bursty Mode\n\n```bash\ncurl -X POST http://localhost:8080/start-cpu \\\n  -H 'Content-Type: application/json' \\\n  -d '{\"mode\":\"bursty\",\"utilization\":60}'\n```\n\nIn this mode:\n- Simulates consumer desktop CPU usage patterns with realistic bursty behavior\n- Alternates between CPU bursts and idle periods using exponential distribution\n- Burst durations: 50ms-1s (exponentially distributed, mean ~300ms)\n- Configurable utilization percentage (0-100, default 50)\n- Uses fresh processes during bursts (avoids scheduler bias)\n- Time-aware metrics track performance only during burst periods\n- Independent random timing per VM instance (desynchronized across hosts)\n\n**Query burst performance:**\n```bash\ncurl http://localhost:8080/burst-perf\n# Returns: 233672 (ops/sec during bursts only)\n```\n\n**When to use:**\n- Testing CPU contention with realistic workload patterns\n- Simulating consumer desktop or mixed workload scenarios\n- Measuring \"how much CPU do we get when we need it?\"\n- Testing multiple VMs with desynchronized load patterns\n\n**Example: Different utilization levels**\n```bash\n# Light bursty load (25% utilization)\ncurl -X POST http://localhost:8080/start-cpu \\\n  -H 'Content-Type: application/json' \\\n  -d '{\"mode\":\"bursty\",\"utilization\":25}'\n\n# Heavy bursty load (75% utilization)\ncurl -X POST http://localhost:8080/start-cpu \\\n  -H 'Content-Type: application/json' \\\n  -d '{\"mode\":\"bursty\",\"utilization\":75}'\n```\n\n#### Switching Modes\n\nYou can switch modes at any time via the API. If the CPU stress test is running, it will automatically restart with the new mode:\n\n```bash\n# Switch from fresh-process to threaded\ncurl -X POST http://localhost:8080/start-cpu \\\n  -H 'Content-Type: application/json' \\\n  -d '{\"mode\":\"threaded\"}'\n\n# Switch to bursty mode\ncurl -X POST http://localhost:8080/start-cpu \\\n  -H 'Content-Type: application/json' \\\n  -d '{\"mode\":\"bursty\",\"utilization\":50}'\n```\n\n## Installation\n\n**Download and run (Linux AMD64):**\n```bash\ncurl -L https://files.tensorturtle.com/yundera-cpu-stress/cpu-stress-linux-amd64 -o cpu-stress \u0026\u0026 chmod +x cpu-stress \u0026\u0026 ./cpu-stress\n```\n\n**Install from crates.io:**\n```bash\ncargo install distributed-cpu-stress-reporter\n```\n\n**Build from source:**\n```bash\ngit clone https://github.com/tensorturtle/distributed-cpu-stress-reporter.git\ncd distributed-cpu-stress-reporter\ncargo build --release\n./target/release/distributed-cpu-stress-reporter\n```\n\n## FAQ\n\n**Q: Will this harm my CPU?**\nA: No. Standard CPU stress test like Prime95.\n\n**Q: How do I stop it?**\nA: `curl -X POST http://localhost:8080/end-cpu` or `Ctrl+C` to exit the application\n\n**Q: Which mode should I use?**\nA:\n- **Fresh-process mode** (default): Most testing scenarios, especially when comparing multiple instances\n- **Threaded mode**: Maximum performance or single instance testing\n- **Bursty mode**: Realistic workload patterns, testing CPU responsiveness during bursts, simulating desktop/mixed workloads\n\n**Q: Can I change the port?**\nA: Edit `src/main.rs:110` and rebuild.\n\n**Q: Works on Windows/macOS/Linux?**\nA: Yes, all platforms Rust supports.\n\n## Troubleshooting\n\n**Port already in use:**\n```bash\nlsof -i :8080  # Find what's using the port\n```\n\n**Can't access from another machine:**\n```bash\nsudo ufw allow 8080/tcp  # Open firewall\n```\n\n**Low performance:**\n```bash\n# Check CPU governor (Linux)\ncat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor\n# Set to performance mode if needed\necho performance | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor\n```\n\n## Performance Expectations\n\n- Modern CPUs: ~200k-500k ops/sec per core\n- 2x overprovisioning: ~50% performance drop\n- Higher = better, consistency indicates fairness\n\n**Tip:** Run on bare metal first to establish baseline.\n\n## License\n\nLicensed under either of:\n\n- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)\n- MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)\n\nat your option.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftensorturtle%2Fdistributed-cpu-stress-reporter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftensorturtle%2Fdistributed-cpu-stress-reporter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftensorturtle%2Fdistributed-cpu-stress-reporter/lists"}