# hsmc dispatch baseline — instruction counts from gungraun.
#
# ─── Harness migration (iai-callgrind 0.16 → gungraun 0.18) ──────────
#
# Switched from iai-callgrind to gungraun (a maintained fork). The
# gungraun harness wraps each bench body with a slightly thicker shim
# (extra `__gungraun_wrapper_id_mod_<id>::<id>` indirection, more
# careful black_box / setup-result handoff), so absolute instruction
# counts are NOT comparable to the iai-callgrind 0.16 numbers in git
# history. The HSM dispatch work itself didn't change between the two
# runs — the harness is just instrumenting more.
#
# Below are the gungraun_initial baselines. Old named baselines
# (pre_lca_fix, before_path_precompute, …) are gone; their deltas live
# in the historical comment block at the bottom for context, but they
# are not directly comparable to current numbers.
#
# Re-run with:
#
#     cargo bench --bench dispatch
#
# Save a named baseline for diffing:
#
#     cargo bench --bench dispatch -- --save-baseline=before_<your_change>
#     <change>
#     cargo bench --bench dispatch -- --baseline=before_<your_change>
#
# Numbers below are from a 6.19.14-zen kernel x86_64 box, valgrind
# 3.25.1, gungraun 0.18.2, gungraun-runner 0.18.2, --release.

dispatch::dispatch::h2_cold_start cold:setup_h2_cold()
  Instructions:                         131
  L1 Hits:                              181
  RAM Hits:                              12
  Estimated Cycles:                     601

dispatch::dispatch::h2_warm_lateral warm:setup_h2_warm()
  Instructions:                         119
  L1 Hits:                              168
  RAM Hits:                               7
  Estimated Cycles:                     413

dispatch::dispatch::h4_cross_tree cross:setup_h4_warm()
  Instructions:                         128
  L1 Hits:                              182
  RAM Hits:                               7
  Estimated Cycles:                     427

dispatch::dispatch::h4_up up:setup_h4_warm()
  Instructions:                         114
  L1 Hits:                              163
  RAM Hits:                               6
  Estimated Cycles:                     373

dispatch::dispatch::h4_self self_:setup_h4_warm()
  Instructions:                         128
  L1 Hits:                              182
  RAM Hits:                               7
  Estimated Cycles:                     427

dispatch::dispatch::h8_cross_tree cross:setup_h8_warm()
  Instructions:                          97
  L1 Hits:                              137
  RAM Hits:                               8
  Estimated Cycles:                     417

dispatch::dispatch::bubble_leaf leaf:setup_bubble_warm()
  Instructions:                         129
  L1 Hits:                              183
  RAM Hits:                               9
  Estimated Cycles:                     498

dispatch::dispatch::bubble_mid mid:setup_bubble_warm()
  Instructions:                         129
  L1 Hits:                              183
  RAM Hits:                               9
  Estimated Cycles:                     498

dispatch::dispatch::bubble_top top:setup_bubble_warm()
  Instructions:                         129
  L1 Hits:                              184
  RAM Hits:                               8
  Estimated Cycles:                     464

dispatch::dispatch::timer_fire_dispatch fire:setup_timer_fire_armed()
  Instructions:                         221
  L1 Hits:                              294
  RAM Hits:                              12
  Estimated Cycles:                     714

dispatch::dispatch::terminate_event quit:setup_term_warm()
  Instructions:                          68
  L1 Hits:                               99
  RAM Hits:                               7
  Estimated Cycles:                     344

dispatch::dispatch::bubble_cross_tree switch:setup_bubble_cross_warm()
  Instructions:                         120
  L1 Hits:                              167
  RAM Hits:                               9
  Estimated Cycles:                     482

dispatch::dispatch::chain_self_emit chain:setup_chain_warm()
  Instructions:                         500
  L1 Hits:                              689
  RAM Hits:                              18
  Estimated Cycles:                    1319

# ─── Historical context (iai-callgrind era, NOT comparable) ─────────
#
# The codebase went through six dispatch-path optimization passes
# under iai-callgrind 0.16 before this harness migration. Cumulative
# results vs. the original O(H²) LCA scan:
#
#   h8_cross_tree    -82% instr / -72% cycles    (deepest LCA stress)
#   terminate_event  -75% instr (combined)       (precomputed exit table)
#
# The passes, in order:
#
#  1. LCA contains() → O(H) ancestor-walk
#  2. Per-state precomputed exit/enter path tables
#  3. Skip empty timer scan in step()
#  4. Per-event handler dispatch table (was __PARENT bubble walk)
#  5. Codegen-elide timer machinery for charts with no `after()` triggers
#  6. Precomputed __TERMINATE_DATA + queue.clear() + u128→u64 nanoseconds
#
# Pre-migration absolute numbers (iai-callgrind 0.16, for reference
# only; do not subtract from gungraun numbers):
#
#   h2_cold_start            38 instr   201 cycles
#   h2_warm_lateral          84 instr   397 cycles
#   h4_cross_tree           101 instr   456 cycles
#   h4_up                    98 instr   384 cycles
#   h4_self                 101 instr   456 cycles
#   h8_cross_tree            93 instr   443 cycles
#   bubble_leaf/mid/top      99 instr   453 cycles
#   timer_fire_dispatch     191 instr   706 cycles
#   terminate_event          69 instr   311 cycles
#   bubble_cross_tree        94 instr   444 cycles
#   chain_self_emit         419 instr  1301 cycles
#
# Most of the absolute-instruction increase under gungraun is
# harness, not HSM. Comparable iai-callgrind/gungraun deltas (e.g.,
# h8_cross_tree 93→97, terminate_event 69→68) confirm the dispatch
# work itself is unchanged.
