pre-ship: resolve the new audio diagnostic gates ONCE instead of per frame

RunSequence and AudioIdleWatcher::Execute run per sequence per frame, so the
BT_ATTRBIND_LOG probes added while chasing #99 were calling getenv ~2700x/sec on
a 15-sequence mech.  Small, but this is the same path the source-pooling fix
(#32) just bought 10% of frame time in, and an unset diagnostic should cost
nothing.  Cached in function-static flags.

Pre-ship smoke (combat, 2 kills, a respawn, clean teardown):
  frame time 7.18 / 8.27 / 8.71 ms  -- matches the post-pooling 7.79ms baseline
  0 asserts, 0 access violations, 0 audio acquireFails

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Joe DiPrima
2026-08-01 20:11:06 -05:00
co-authored by Claude Opus 5
parent 7c08e8bd03
commit 5a1a407ed1
3 changed files with 20 additions and 4 deletions
+4 -3
View File
@@ -475,7 +475,8 @@ void
//
// #99 probe: PER-SEQUENCE throttle. A single shared counter here hid the
// alarm sequence entirely -- the busy sequences ate every slot.
if (getenv("BT_ATTRBIND_LOG") && isLooped) { if (runProbeCount < 6)
static const int s_seqDiag = (getenv("BT_ATTRBIND_LOG") != 0); // hot path: resolve once
if (s_seqDiag && isLooped) { if (runProbeCount < 6)
{ ++runProbeCount;
DEBUG_STREAM << "[seqrun] seq=" << (void *)this
<< " isRunning=" << (int)isRunning
@@ -494,7 +495,7 @@ void
Check(audioControlEventIterator);
control_event = audioControlEventIterator->GetCurrent();
if (getenv("BT_ATTRBIND_LOG")) { static int s_nr=0;
if (s_seqDiag) { static int s_nr=0;
if (control_event != NULL && !IsEventReady(control_event) && (s_nr++ % 500)==0)
{
AudioTime off(startTime);
@@ -539,7 +540,7 @@ void
// Send the controller to the connected audio component
//
Check(control_event);
if (getenv("BT_ATTRBIND_LOG")) { static int s_se=0; if (s_se++<60)
if (s_seqDiag) { static int s_se=0; if (s_se++<60)
DEBUG_STREAM << "[seqsend] seq=" << (void *)this
<< " -> comp=" << (void *)audioComponentSocket.GetCurrent()
<< " ctl=" << (int)control_event->audioControlID
+2 -1
View File
@@ -112,7 +112,8 @@ void
{
Check(this);
Check(audioComponentSocket.GetCurrent());
if (getenv("BT_ATTRBIND_LOG")) { static int s_iw=0; if ((s_iw++ % 400)==0)
static const int s_idleDiag = (getenv("BT_ATTRBIND_LOG") != 0); // hot path: resolve once
if (s_idleDiag) { static int s_iw=0; if ((s_iw++ % 400)==0)
DEBUG_STREAM << "[idlewatch] #" << s_iw << " comp="
<< (void *)audioComponentSocket.GetCurrent() << std::endl; }
audioComponentSocket.GetCurrent()->ReceiveControl(
+14
View File
@@ -0,0 +1,14 @@
#!/usr/bin/env bash
# Pre-ship smoke: combat, no diagnostics, measure frame time + confirm no crash.
set -x
. /c/git/bt411/scratchpad/night6/bench_common.sh
cd /c/git/bt411/content || exit 1
taskkill //F //IM btl4.exe > /dev/null 2>&1
sleep 2
sed "s/^map=.*/map=grass/; s/^time=.*/time=day/" MP.EGG > SHIP.EGG
rm -f preship.log
export BT_SPAWN_ENEMY=2 BT_AUTOFIRE=1 BT_GOTO=enemy BT_GOTO_STOP=40
bt_launch preship.log SHIP.EGG 0x03
sleep 120
taskkill //F //IM btl4.exe > /dev/null 2>&1
sleep 2