Commit Graph
9 Commits
Author SHA1 Message Date
J. Nick Koston 4535b82483 [scheduler] Remove redundant Defer_UniqueID, keep anonymous + same-ID
UniqueID benchmark was unrealistic — unique IDs still ran
cancel_item_locked_ scanning all containers for matches that never
exist. Replace with just two meaningful defer variants:
- Defer: anonymous (nullptr name, skips cancel entirely)
- Defer_SameID: fixed ID (cancel-and-replace coalescing pattern)
2026-04-02 11:51:52 -10:00
J. Nick Koston ed14694e46 [scheduler] Add defer benchmark variants and fix anonymous defer path
- Scheduler_Defer: use nullptr name matching Component::defer(func)
  production pattern (skips cancel_item_locked_ entirely)
- Scheduler_Defer_SameID: fixed ID 0 measuring cancel-and-replace
  pattern for coalescing rapid updates
- Scheduler_Defer_UniqueID: unique IDs measuring cancel scan overhead
  when no match is found
2026-04-02 11:45:03 -10:00
J. Nick Koston ce5c36a02a [scheduler] Fix pool imbalance in benchmarks, add static_assert
Change kInnerIterations from 2000 to 2100 (divisible by batch sizes 3
and 10) to prevent pool imbalance at iteration boundaries that caused
spurious malloc. Add static_assert to each benchmark to catch this at
compile time.
2026-04-02 11:38:18 -10:00
J. Nick Koston 904577bf91 [scheduler] Extract warm_pool helper for scheduler benchmarks
Replace duplicated pool warmup blocks with a shared warm_pool() helper
that registers and replaces items twice to populate the recycling pool
before the benchmark loop begins.
2026-04-02 11:31:27 -10:00
J. Nick Koston 279686b1c2 [scheduler] Add ExceedPool benchmark to measure pool overflow cliff
Add Scheduler_SetTimeout_ExceedPool with batch size 10 (exceeding
MAX_POOL_SIZE=5) to measure the performance impact when the recycling
pool is exhausted and items must be malloc'd/freed each cycle.
2026-04-02 11:26:28 -10:00
J. Nick Koston 615b2b339a [scheduler] Batch 3 registrations per call() for realistic worst case
Instead of draining after every single registration or batching 5,
use a batch size of 3 which represents a realistic worst case where
multiple components schedule in the same loop iteration while staying
within the recycling pool (MAX_POOL_SIZE=5).
2026-04-02 11:24:53 -10:00
J. Nick Koston 347f981768 [scheduler] Fix unrealistic scheduler benchmarks missing periodic drain
Scheduler registration benchmarks (SetTimeout, SetInterval, Defer) were
not calling scheduler.call() periodically to drain and clean up cancelled
items. In production, call() runs every loop iteration, keeping the
scheduler containers small. Without draining, cancelled items accumulated
causing O(n²) scan cost in cancel_item_locked_ that doesn't reflect
real-world behavior.

- SetTimeout: was only calling process_to_add() (no cleanup), now calls
  call() every kKeyCount iterations
- SetInterval: was calling process_to_add() (no cleanup of items_), now
  calls call() for proper cleanup
- Defer: was never draining the defer queue, now calls call() to process
  deferred items as production does
- All three now advance time (++now) to match production loop behavior
2026-04-02 11:18:17 -10:00
J. Nick Koston 9a80c980cb [scheduler] Early exit cancel path after first match (#14902) 2026-03-18 07:48:26 -10:00
J. Nick Koston 1670f04a87 [core] Add CodSpeed C++ benchmarks for protobuf, main loop, and helpers (#14878) 2026-03-17 12:29:38 -10:00