mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-08-06 22:08:41 +00:00
further pass over call stack cache lookup path
This commit is contained in:
+19
-7
@@ -3359,25 +3359,30 @@ internal CTRL_CallStack
|
|||||||
ctrl_call_stack_from_thread(CTRL_Scope *scope, CTRL_EntityCtx *entity_ctx, CTRL_Entity *thread, B32 high_priority, U64 endt_us)
|
ctrl_call_stack_from_thread(CTRL_Scope *scope, CTRL_EntityCtx *entity_ctx, CTRL_Entity *thread, B32 high_priority, U64 endt_us)
|
||||||
{
|
{
|
||||||
CTRL_CallStack call_stack = {0};
|
CTRL_CallStack call_stack = {0};
|
||||||
{
|
|
||||||
CTRL_CallStackCache *cache = &ctrl_state->call_stack_cache;
|
CTRL_CallStackCache *cache = &ctrl_state->call_stack_cache;
|
||||||
|
|
||||||
|
//////////////////////////////
|
||||||
//- rjf: unpack thread
|
//- rjf: unpack thread
|
||||||
|
//
|
||||||
CTRL_Handle handle = thread->handle;
|
CTRL_Handle handle = thread->handle;
|
||||||
U64 hash = ctrl_hash_from_handle(handle);
|
U64 hash = ctrl_hash_from_handle(handle);
|
||||||
U64 slot_idx = hash%cache->slots_count;
|
U64 slot_idx = hash%cache->slots_count;
|
||||||
U64 stripe_idx = slot_idx%cache->stripes_count;
|
U64 stripe_idx = slot_idx%cache->stripes_count;
|
||||||
CTRL_CallStackCacheSlot *slot = &cache->slots[slot_idx];
|
CTRL_CallStackCacheSlot *slot = &cache->slots[slot_idx];
|
||||||
CTRL_CallStackCacheStripe *stripe = &cache->stripes[stripe_idx];
|
CTRL_CallStackCacheStripe *stripe = &cache->stripes[stripe_idx];
|
||||||
|
|
||||||
//- rjf: loop: try to grab cached call stack; request; wait
|
|
||||||
U64 reg_gen = ctrl_reg_gen();
|
U64 reg_gen = ctrl_reg_gen();
|
||||||
U64 mem_gen = ctrl_mem_gen();
|
U64 mem_gen = ctrl_mem_gen();
|
||||||
|
|
||||||
|
//////////////////////////////
|
||||||
|
//- rjf: loop: try to grab cached call stack; request; wait
|
||||||
|
//
|
||||||
OS_MutexScopeR(stripe->rw_mutex) for(;;)
|
OS_MutexScopeR(stripe->rw_mutex) for(;;)
|
||||||
{
|
{
|
||||||
|
////////////////////////////
|
||||||
//- rjf: try to grab cached
|
//- rjf: try to grab cached
|
||||||
|
//
|
||||||
B32 is_good = 0;
|
B32 is_good = 0;
|
||||||
B32 is_stale = 0;
|
B32 is_stale = 1;
|
||||||
B32 is_working = 0;
|
B32 is_working = 0;
|
||||||
CTRL_CallStackCacheNode *node = 0;
|
CTRL_CallStackCacheNode *node = 0;
|
||||||
{
|
{
|
||||||
@@ -3396,7 +3401,9 @@ ctrl_call_stack_from_thread(CTRL_Scope *scope, CTRL_EntityCtx *entity_ctx, CTRL_
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////
|
||||||
//- rjf: create node if needed
|
//- rjf: create node if needed
|
||||||
|
//
|
||||||
if(!is_good) OS_MutexScopeRWPromote(stripe->rw_mutex)
|
if(!is_good) OS_MutexScopeRWPromote(stripe->rw_mutex)
|
||||||
{
|
{
|
||||||
node = 0;
|
node = 0;
|
||||||
@@ -3416,8 +3423,10 @@ ctrl_call_stack_from_thread(CTRL_Scope *scope, CTRL_EntityCtx *entity_ctx, CTRL_
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////
|
||||||
//- rjf: request if needed
|
//- rjf: request if needed
|
||||||
if(!is_working && (!is_good || is_stale))
|
//
|
||||||
|
if(node != 0 && !is_working && is_stale)
|
||||||
{
|
{
|
||||||
if(ctrl_u2csb_enqueue_req(thread->handle, endt_us) &&
|
if(ctrl_u2csb_enqueue_req(thread->handle, endt_us) &&
|
||||||
async_push_work(ctrl_call_stack_build_work, .priority = high_priority ? ASYNC_Priority_High : ASYNC_Priority_Low))
|
async_push_work(ctrl_call_stack_build_work, .priority = high_priority ? ASYNC_Priority_High : ASYNC_Priority_Low))
|
||||||
@@ -3426,16 +3435,19 @@ ctrl_call_stack_from_thread(CTRL_Scope *scope, CTRL_EntityCtx *entity_ctx, CTRL_
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////
|
||||||
//- rjf: good, or timeout? -> exit
|
//- rjf: good, or timeout? -> exit
|
||||||
if((is_good && !is_stale) || os_now_microseconds() >= endt_us)
|
//
|
||||||
|
if(!is_stale || os_now_microseconds() >= endt_us)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////
|
||||||
//- rjf: time to wait for new result? -> wait
|
//- rjf: time to wait for new result? -> wait
|
||||||
|
//
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return call_stack;
|
return call_stack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user