defer call stack scope touches until retry loop exit

This commit is contained in:
Ryan Fleury
2025-05-21 17:33:30 -07:00
parent b0fb102813
commit 895a965f70
+10 -2
View File
@@ -3399,7 +3399,10 @@ ctrl_call_stack_from_thread(CTRL_Scope *scope, CTRL_EntityCtx *entity_ctx, CTRL_
// //
B32 can_request = !ins_atomic_u64_eval(&ctrl_state->ctrl_thread_run_state); B32 can_request = !ins_atomic_u64_eval(&ctrl_state->ctrl_thread_run_state);
B32 did_request = 0; B32 did_request = 0;
OS_MutexScopeR(stripe->rw_mutex) for(;;) OS_MutexScopeR(stripe->rw_mutex)
{
CTRL_CallStackCacheNode *taken_node = 0;
for(;;)
{ {
//////////////////////////// ////////////////////////////
//- rjf: try to grab cached //- rjf: try to grab cached
@@ -3418,7 +3421,7 @@ ctrl_call_stack_from_thread(CTRL_Scope *scope, CTRL_EntityCtx *entity_ctx, CTRL_
is_stale = (reg_gen > n->reg_gen || mem_gen > n->mem_gen); is_stale = (reg_gen > n->reg_gen || mem_gen > n->mem_gen);
is_working = (n->working_count > 0); is_working = (n->working_count > 0);
call_stack = n->call_stack; call_stack = n->call_stack;
ctrl_scope_touch_call_stack_node__stripe_r_guarded(scope, stripe, n); taken_node = node;
break; break;
} }
} }
@@ -3480,6 +3483,11 @@ ctrl_call_stack_from_thread(CTRL_Scope *scope, CTRL_EntityCtx *entity_ctx, CTRL_
os_condition_variable_wait_rw_r(stripe->cv, stripe->rw_mutex, endt_us); os_condition_variable_wait_rw_r(stripe->cv, stripe->rw_mutex, endt_us);
} }
} }
if(taken_node != 0)
{
ctrl_scope_touch_call_stack_node__stripe_r_guarded(scope, stripe, taken_node);
}
}
return call_stack; return call_stack;
} }