mirror of
https://github.com/agent-substrate/substrate.git
synced 2026-11-10 10:13:50 +08:00
Benchmark actors that are idle processes understate what a real agent costs a node: an agent keeps some CPU busy even between requests. This adds a way to give glutton actors a steady, tunable CPU draw. Glutton gains a UseCPU RPC (also served over HTTP at /usecpu) that replaces its pool of CPU-burning goroutines. Each goroutine targets a duty cycle of one core, and measures its work budget in thread CPU time so time spent preempted is not counted as work. The pool size is capped at GOMAXPROCS unless the caller opts out, is reported by the glutton.cpu.workers gauge, and is stopped on Close. The boomer GluttonUser drives it through two new dynconfig keys, cpu_cores and cpu_duty_cycle, set from the locust --cpu-cores and --cpu-duty-cycle flags. Like the RAM fill, the load is started once per actor after its first resume: the goroutines live in the glutton process, so they persist across suspend and resume. A failed request is retried on the next iteration, and the call reports as its own GluttonUseCPU stats row. Zero cores, the default, disables it. Fixes #<issue_number_goes_here> > It's a good idea to open an issue first for discussion. - [ x ] Tests pass - [ x ] Appropriate changes to documentation are included in the PR