diff --git a/src/base/base_entry_point.c b/src/base/base_entry_point.c index 018cb46a..c35ca2eb 100644 --- a/src/base/base_entry_point.c +++ b/src/base/base_entry_point.c @@ -1,6 +1,8 @@ // Copyright (c) 2024 Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) +global U64 global_update_tick_idx = 0; + internal void main_thread_base_entry_point(void (*entry_point)(CmdLine *cmdline), char **arguments, U64 arguments_count) { @@ -48,11 +50,11 @@ main_thread_base_entry_point(void (*entry_point)(CmdLine *cmdline), char **argum #if defined(DASM_CACHE_H) && !defined(DASM_INIT_MANUAL) dasm_init(); #endif -#if defined(DBGI_H) && !defined(DBGI_INIT_MANUAL) +#if defined(DBGI_H) && !defined(DI_INIT_MANUAL) di_init(); #endif -#if defined(FUZZY_SEARCH_H) && !defined(FZY_INIT_MANUAL) - fzy_init(); +#if defined(DBGI_SEARCH_H) && !defined(DIS_INIT_MANUAL) + dis_init(); #endif #if defined(DEMON_CORE_H) && !defined(DMN_INIT_MANUAL) dmn_init(); @@ -105,22 +107,18 @@ supplement_thread_base_entry_point(void (*entry_point)(void *params), void *para tctx_release(); } +internal U64 +update_tick_idx(void) +{ + U64 result = ins_atomic_u64_eval(&global_update_tick_idx); + return result; +} + internal B32 update(void) { ProfTick(0); -#if defined(TEXT_CACHE_H) - txt_user_clock_tick(); -#endif -#if defined(DASM_CACHE_H) - dasm_user_clock_tick(); -#endif -#if defined(GEO_CACHE_H) - geo_user_clock_tick(); -#endif -#if defined(TEXTURE_CACHE_H) - tex_user_clock_tick(); -#endif + ins_atomic_u64_inc_eval(&global_update_tick_idx); #if OS_FEATURE_GRAPHICAL B32 result = frame(); #else diff --git a/src/base/base_entry_point.h b/src/base/base_entry_point.h index bf8d57de..dc739fce 100644 --- a/src/base/base_entry_point.h +++ b/src/base/base_entry_point.h @@ -6,6 +6,7 @@ internal void main_thread_base_entry_point(void (*entry_point)(CmdLine *cmdline), char **arguments, U64 arguments_count); internal void supplement_thread_base_entry_point(void (*entry_point)(void *params), void *params); +internal U64 update_tick_idx(void); internal B32 update(void); #endif // BASE_ENTRY_POINT_H diff --git a/src/dasm_cache/dasm_cache.c b/src/dasm_cache/dasm_cache.c index 156678d5..f0ccb674 100644 --- a/src/dasm_cache/dasm_cache.c +++ b/src/dasm_cache/dasm_cache.c @@ -277,22 +277,6 @@ dasm_init(void) dasm_shared->evictor_detector_thread = os_thread_launch(dasm_evictor_detector_thread__entry_point, 0, 0); } -//////////////////////////////// -//~ rjf: User Clock - -internal void -dasm_user_clock_tick(void) -{ - ins_atomic_u64_inc_eval(&dasm_shared->user_clock_idx); -} - -internal U64 -dasm_user_clock_idx(void) -{ - U64 idx = ins_atomic_u64_eval(&dasm_shared->user_clock_idx); - return idx; -} - //////////////////////////////// //~ rjf: Scoped Access @@ -342,7 +326,7 @@ dasm_scope_touch_node__stripe_r_guarded(DASM_Scope *scope, DASM_Node *node) DASM_Touch *touch = push_array(dasm_tctx->arena, DASM_Touch, 1); ins_atomic_u64_inc_eval(&node->scope_ref_count); ins_atomic_u64_eval_assign(&node->last_time_touched_us, os_now_microseconds()); - ins_atomic_u64_eval_assign(&node->last_user_clock_idx_touched, dasm_user_clock_idx()); + ins_atomic_u64_eval_assign(&node->last_user_clock_idx_touched, update_tick_idx()); touch->hash = node->hash; MemoryCopyStruct(&touch->params, &node->params); touch->params.dbgi_key = di_key_copy(dasm_tctx->arena, &touch->params.dbgi_key); @@ -804,7 +788,7 @@ dasm_evictor_detector_thread__entry_point(void *p) { U64 change_gen = fs_change_gen(); U64 check_time_us = os_now_microseconds(); - U64 check_time_user_clocks = dasm_user_clock_idx(); + U64 check_time_user_clocks = update_tick_idx(); U64 evict_threshold_us = 10*1000000; U64 retry_threshold_us = 1*1000000; U64 evict_threshold_user_clocks = 10; diff --git a/src/dasm_cache/dasm_cache.h b/src/dasm_cache/dasm_cache.h index 5ce7ea00..2d670111 100644 --- a/src/dasm_cache/dasm_cache.h +++ b/src/dasm_cache/dasm_cache.h @@ -246,9 +246,6 @@ struct DASM_Shared { Arena *arena; - // rjf: user clock - U64 user_clock_idx; - // rjf: cache U64 slots_count; U64 stripes_count; @@ -301,12 +298,6 @@ internal U64 dasm_line_array_code_off_from_idx(DASM_LineArray *array, U64 idx); internal void dasm_init(void); -//////////////////////////////// -//~ rjf: User Clock - -internal void dasm_user_clock_tick(void); -internal U64 dasm_user_clock_idx(void); - //////////////////////////////// //~ rjf: Scoped Access diff --git a/src/dbgi/dbgi.c b/src/dbgi/dbgi.c index fc549f8d..e7997e7e 100644 --- a/src/dbgi/dbgi.c +++ b/src/dbgi/dbgi.c @@ -72,7 +72,7 @@ di_key_array_from_list(Arena *arena, DI_KeyList *list) MemoryCopyStruct(&array.v[idx], &n->v); } return array; -} +} //////////////////////////////// //~ rjf: Main Layer Initialization @@ -96,7 +96,7 @@ di_init(void) di_shared->u2p_ring_mutex = os_mutex_alloc(); di_shared->u2p_ring_cv = os_condition_variable_alloc(); di_shared->u2p_ring_size = KB(64); - di_shared->u2p_ring_base = push_array_no_zero(arena, U8, di_shared->u2p_ring_size); + di_shared->u2p_ring_base = push_array_no_zero(arena, U8, di_shared->u2p_ring_size); di_shared->p2u_ring_mutex = os_mutex_alloc(); di_shared->p2u_ring_cv = os_condition_variable_alloc(); di_shared->p2u_ring_size = KB(64); @@ -470,7 +470,7 @@ di_rdi_from_key(DI_Scope *scope, DI_Key *key, U64 endt_us) scratch_end(scratch); } return result; -} +} //////////////////////////////// //~ rjf: Parse Threads diff --git a/src/dbgi/dbgi.h b/src/dbgi/dbgi.h index 03ebb3d3..1da43792 100644 --- a/src/dbgi/dbgi.h +++ b/src/dbgi/dbgi.h @@ -72,7 +72,7 @@ struct DI_EventList }; //////////////////////////////// -//~ rjf: Cache Types +//~ rjf: Debug Info Cache Types typedef struct DI_StringChunkNode DI_StringChunkNode; struct DI_StringChunkNode @@ -161,7 +161,7 @@ struct DI_Shared { Arena *arena; - // rjf: node cache + // rjf: debug info cache U64 slots_count; DI_Slot *slots; U64 stripes_count; @@ -239,7 +239,7 @@ internal void di_close(DI_Key *key); internal RDI_Parsed *di_rdi_from_key(DI_Scope *scope, DI_Key *key, U64 endt_us); //////////////////////////////// -//~ rjf: Parse Threads +//~ rjf: Asynchronous Parse Work internal B32 di_u2p_enqueue_key(DI_Key *key, U64 endt_us); internal void di_u2p_dequeue_key(Arena *arena, DI_Key *out_key); diff --git a/src/fuzzy_search/fuzzy_search.c b/src/dbgi_search/dbgi_search.c similarity index 71% rename from src/fuzzy_search/fuzzy_search.c rename to src/dbgi_search/dbgi_search.c index 406ce42f..a322bd1e 100644 --- a/src/fuzzy_search/fuzzy_search.c +++ b/src/dbgi_search/dbgi_search.c @@ -5,7 +5,7 @@ //~ rjf: Helpers internal U64 -fzy_hash_from_string(U64 seed, String8 string) +dis_hash_from_string(U64 seed, String8 string) { U64 result = seed; for(U64 i = 0; i < string.size; i += 1) @@ -16,20 +16,20 @@ fzy_hash_from_string(U64 seed, String8 string) } internal U64 -fzy_hash_from_params(FZY_Params *params) +dis_hash_from_params(DIS_Params *params) { U64 hash = 5381; - hash = fzy_hash_from_string(hash, str8_struct(¶ms->target)); + hash = dis_hash_from_string(hash, str8_struct(¶ms->target)); for(U64 idx = 0; idx < params->dbgi_keys.count; idx += 1) { - hash = fzy_hash_from_string(hash, str8_struct(¶ms->dbgi_keys.v[idx].min_timestamp)); - hash = fzy_hash_from_string(hash, params->dbgi_keys.v[idx].path); + hash = dis_hash_from_string(hash, str8_struct(¶ms->dbgi_keys.v[idx].min_timestamp)); + hash = dis_hash_from_string(hash, params->dbgi_keys.v[idx].path); } return hash; } internal U64 -fzy_item_num_from_array_element_idx__linear_search(FZY_ItemArray *array, U64 element_idx) +dis_item_num_from_array_element_idx__linear_search(DIS_ItemArray *array, U64 element_idx) { U64 fuzzy_item_num = 0; for(U64 idx = 0; idx < array->count; idx += 1) @@ -44,7 +44,7 @@ fzy_item_num_from_array_element_idx__linear_search(FZY_ItemArray *array, U64 ele } internal String8 -fzy_item_string_from_rdi_target_element_idx(RDI_Parsed *rdi, RDI_SectionKind target, U64 element_idx) +dis_item_string_from_rdi_target_element_idx(RDI_Parsed *rdi, RDI_SectionKind target, U64 element_idx) { String8 result = {0}; switch(target) @@ -83,10 +83,10 @@ fzy_item_string_from_rdi_target_element_idx(RDI_Parsed *rdi, RDI_SectionKind tar return result; } -internal FZY_Params -fzy_params_copy(Arena *arena, FZY_Params *src) +internal DIS_Params +dis_params_copy(Arena *arena, DIS_Params *src) { - FZY_Params dst = zero_struct; + DIS_Params dst = zero_struct; MemoryCopyStruct(&dst, src); dst.dbgi_keys.v = push_array(arena, DI_Key, dst.dbgi_keys.count); MemoryCopy(dst.dbgi_keys.v, src->dbgi_keys.v, sizeof(DI_Key)*src->dbgi_keys.count); @@ -101,88 +101,88 @@ fzy_params_copy(Arena *arena, FZY_Params *src) //~ rjf: Main Layer Initialization internal void -fzy_init(void) +dis_init(void) { Arena *arena = arena_alloc(); - fzy_shared = push_array(arena, FZY_Shared, 1); - fzy_shared->arena = arena; - fzy_shared->slots_count = 256; - fzy_shared->stripes_count = os_get_system_info()->logical_processor_count; - fzy_shared->slots = push_array(arena, FZY_Slot, fzy_shared->slots_count); - fzy_shared->stripes = push_array(arena, FZY_Stripe, fzy_shared->stripes_count); - for(U64 idx = 0; idx < fzy_shared->stripes_count; idx += 1) + dis_shared = push_array(arena, DIS_Shared, 1); + dis_shared->arena = arena; + dis_shared->slots_count = 256; + dis_shared->stripes_count = os_get_system_info()->logical_processor_count; + dis_shared->slots = push_array(arena, DIS_Slot, dis_shared->slots_count); + dis_shared->stripes = push_array(arena, DIS_Stripe, dis_shared->stripes_count); + for(U64 idx = 0; idx < dis_shared->stripes_count; idx += 1) { - fzy_shared->stripes[idx].arena = arena_alloc(); - fzy_shared->stripes[idx].rw_mutex = os_rw_mutex_alloc(); - fzy_shared->stripes[idx].cv = os_condition_variable_alloc(); + dis_shared->stripes[idx].arena = arena_alloc(); + dis_shared->stripes[idx].rw_mutex = os_rw_mutex_alloc(); + dis_shared->stripes[idx].cv = os_condition_variable_alloc(); } - fzy_shared->thread_count = Min(os_get_system_info()->logical_processor_count, 2); - fzy_shared->threads = push_array(arena, FZY_Thread, fzy_shared->thread_count); - for(U64 idx = 0; idx < fzy_shared->thread_count; idx += 1) + dis_shared->thread_count = Min(os_get_system_info()->logical_processor_count, 2); + dis_shared->threads = push_array(arena, DIS_Thread, dis_shared->thread_count); + for(U64 idx = 0; idx < dis_shared->thread_count; idx += 1) { - fzy_shared->threads[idx].u2f_ring_mutex = os_mutex_alloc(); - fzy_shared->threads[idx].u2f_ring_cv = os_condition_variable_alloc(); - fzy_shared->threads[idx].u2f_ring_size = KB(64); - fzy_shared->threads[idx].u2f_ring_base = push_array_no_zero(arena, U8, fzy_shared->threads[idx].u2f_ring_size); - fzy_shared->threads[idx].thread = os_thread_launch(fzy_search_thread__entry_point, (void *)idx, 0); + dis_shared->threads[idx].u2f_ring_mutex = os_mutex_alloc(); + dis_shared->threads[idx].u2f_ring_cv = os_condition_variable_alloc(); + dis_shared->threads[idx].u2f_ring_size = KB(64); + dis_shared->threads[idx].u2f_ring_base = push_array_no_zero(arena, U8, dis_shared->threads[idx].u2f_ring_size); + dis_shared->threads[idx].thread = os_thread_launch(dis_search_thread__entry_point, (void *)idx, 0); } } //////////////////////////////// //~ rjf: Scope Functions -internal FZY_Scope * -fzy_scope_open(void) +internal DIS_Scope * +dis_scope_open(void) { - if(fzy_tctx == 0) + if(dis_tctx == 0) { Arena *arena = arena_alloc(); - fzy_tctx = push_array(arena, FZY_TCTX, 1); - fzy_tctx->arena = arena; + dis_tctx = push_array(arena, DIS_TCTX, 1); + dis_tctx->arena = arena; } - FZY_Scope *scope = fzy_tctx->free_scope; + DIS_Scope *scope = dis_tctx->free_scope; if(scope != 0) { - SLLStackPop(fzy_tctx->free_scope); + SLLStackPop(dis_tctx->free_scope); } else { - scope = push_array_no_zero(fzy_tctx->arena, FZY_Scope, 1); + scope = push_array_no_zero(dis_tctx->arena, DIS_Scope, 1); } MemoryZeroStruct(scope); return scope; } internal void -fzy_scope_close(FZY_Scope *scope) +dis_scope_close(DIS_Scope *scope) { - for(FZY_Touch *t = scope->first_touch, *next = 0; t != 0; t = next) + for(DIS_Touch *t = scope->first_touch, *next = 0; t != 0; t = next) { next = t->next; - SLLStackPush(fzy_tctx->free_touch, t); + SLLStackPush(dis_tctx->free_touch, t); if(t->node != 0) { ins_atomic_u64_dec_eval(&t->node->touch_count); } } - SLLStackPush(fzy_tctx->free_scope, scope); + SLLStackPush(dis_tctx->free_scope, scope); } internal void -fzy_scope_touch_node__stripe_mutex_r_guarded(FZY_Scope *scope, FZY_Node *node) +dis_scope_touch_node__stripe_mutex_r_guarded(DIS_Scope *scope, DIS_Node *node) { if(node != 0) { ins_atomic_u64_inc_eval(&node->touch_count); } - FZY_Touch *touch = fzy_tctx->free_touch; + DIS_Touch *touch = dis_tctx->free_touch; if(touch != 0) { - SLLStackPop(fzy_tctx->free_touch); + SLLStackPop(dis_tctx->free_touch); } else { - touch = push_array_no_zero(fzy_tctx->arena, FZY_Touch, 1); + touch = push_array_no_zero(dis_tctx->arena, DIS_Touch, 1); } MemoryZeroStruct(touch); SLLQueuePush(scope->first_touch, scope->last_touch, touch); @@ -192,27 +192,27 @@ fzy_scope_touch_node__stripe_mutex_r_guarded(FZY_Scope *scope, FZY_Node *node) //////////////////////////////// //~ rjf: Cache Lookup Functions -internal FZY_ItemArray -fzy_items_from_key_params_query(FZY_Scope *scope, U128 key, FZY_Params *params, String8 query, U64 endt_us, B32 *stale_out) +internal DIS_ItemArray +dis_items_from_key_params_query(DIS_Scope *scope, U128 key, DIS_Params *params, String8 query, U64 endt_us, B32 *stale_out) { Temp scratch = scratch_begin(0, 0); - FZY_ItemArray items = {0}; + DIS_ItemArray items = {0}; //- rjf: hash parameters - U64 params_hash = fzy_hash_from_params(params); + U64 params_hash = dis_hash_from_params(params); //- rjf: unpack key - U64 slot_idx = key.u64[1]%fzy_shared->slots_count; - U64 stripe_idx = slot_idx%fzy_shared->stripes_count; - FZY_Slot *slot = &fzy_shared->slots[slot_idx]; - FZY_Stripe *stripe = &fzy_shared->stripes[stripe_idx]; + U64 slot_idx = key.u64[1]%dis_shared->slots_count; + U64 stripe_idx = slot_idx%dis_shared->stripes_count; + DIS_Slot *slot = &dis_shared->slots[slot_idx]; + DIS_Stripe *stripe = &dis_shared->stripes[stripe_idx]; //- rjf: query and/or request OS_MutexScopeR(stripe->rw_mutex) for(;;) { // rjf: map key -> node - FZY_Node *node = 0; - for(FZY_Node *n = slot->first; n != 0; n = n->next) + DIS_Node *node = 0; + for(DIS_Node *n = slot->first; n != 0; n = n->next) { if(u128_match(n->key, key)) { @@ -224,7 +224,7 @@ fzy_items_from_key_params_query(FZY_Scope *scope, U128 key, FZY_Params *params, // rjf: no node? -> allocate if(node == 0) OS_MutexScopeRWPromote(stripe->rw_mutex) { - node = push_array(stripe->arena, FZY_Node, 1); + node = push_array(stripe->arena, DIS_Node, 1); SLLQueuePush(slot->first, slot->last, node); node->key = key; for(U64 idx = 0; idx < ArrayCount(node->buckets); idx += 1) @@ -238,7 +238,7 @@ fzy_items_from_key_params_query(FZY_Scope *scope, U128 key, FZY_Params *params, if(params_hash == node->buckets[node->gen%ArrayCount(node->buckets)].params_hash && node->gen != 0) { - fzy_scope_touch_node__stripe_mutex_r_guarded(scope, node); + dis_scope_touch_node__stripe_mutex_r_guarded(scope, node); items = node->gen_items; stale = !str8_match(query, node->buckets[node->gen%ArrayCount(node->buckets)].query, 0); if(stale_out != 0) @@ -255,11 +255,11 @@ fzy_items_from_key_params_query(FZY_Scope *scope, U128 key, FZY_Params *params, node->submit_gen += 1; arena_clear(node->buckets[node->submit_gen%ArrayCount(node->buckets)].arena); node->buckets[node->submit_gen%ArrayCount(node->buckets)].query = push_str8_copy(node->buckets[node->submit_gen%ArrayCount(node->buckets)].arena, query); - node->buckets[node->submit_gen%ArrayCount(node->buckets)].params = fzy_params_copy(node->buckets[node->submit_gen%ArrayCount(node->buckets)].arena, params); + node->buckets[node->submit_gen%ArrayCount(node->buckets)].params = dis_params_copy(node->buckets[node->submit_gen%ArrayCount(node->buckets)].arena, params); node->buckets[node->submit_gen%ArrayCount(node->buckets)].params_hash = params_hash; } if((node->submit_gen > node->gen+1 || os_now_microseconds() >= node->last_time_submitted_us+100000) && - fzy_u2s_enqueue_req(key, endt_us)) + dis_u2s_enqueue_req(key, endt_us)) { node->last_time_submitted_us = os_now_microseconds(); } @@ -283,10 +283,10 @@ fzy_items_from_key_params_query(FZY_Scope *scope, U128 key, FZY_Params *params, //~ rjf: Searcher Threads internal B32 -fzy_u2s_enqueue_req(U128 key, U64 endt_us) +dis_u2s_enqueue_req(U128 key, U64 endt_us) { B32 sent = 0; - FZY_Thread *thread = &fzy_shared->threads[key.u64[1]%fzy_shared->thread_count]; + DIS_Thread *thread = &dis_shared->threads[key.u64[1]%dis_shared->thread_count]; OS_MutexScope(thread->u2f_ring_mutex) for(;;) { U64 unconsumed_size = thread->u2f_ring_write_pos - thread->u2f_ring_read_pos; @@ -307,7 +307,7 @@ fzy_u2s_enqueue_req(U128 key, U64 endt_us) } internal void -fzy_u2s_dequeue_req(Arena *arena, FZY_Thread *thread, U128 *key_out) +dis_u2s_dequeue_req(Arena *arena, DIS_Thread *thread, U128 *key_out) { OS_MutexScope(thread->u2f_ring_mutex) for(;;) { @@ -323,7 +323,7 @@ fzy_u2s_dequeue_req(Arena *arena, FZY_Thread *thread, U128 *key_out) } internal int -fzy_qsort_compare_items(FZY_Item *a, FZY_Item *b) +dis_qsort_compare_items(DIS_Item *a, DIS_Item *b) { int result = 0; if(a->match_ranges.count > b->match_ranges.count) @@ -346,10 +346,10 @@ fzy_qsort_compare_items(FZY_Item *a, FZY_Item *b) } internal void -fzy_search_thread__entry_point(void *p) +dis_search_thread__entry_point(void *p) { ThreadNameF("[fzy] searcher #%I64u", (U64)p); - FZY_Thread *thread = &fzy_shared->threads[(U64)p]; + DIS_Thread *thread = &dis_shared->threads[(U64)p]; for(;;) { Temp scratch = scratch_begin(0, 0); @@ -359,11 +359,11 @@ fzy_search_thread__entry_point(void *p) //- rjf: dequeue next request // U128 key = {0}; - fzy_u2s_dequeue_req(scratch.arena, thread, &key); - U64 slot_idx = key.u64[1]%fzy_shared->slots_count; - U64 stripe_idx = slot_idx%fzy_shared->stripes_count; - FZY_Slot *slot = &fzy_shared->slots[slot_idx]; - FZY_Stripe *stripe = &fzy_shared->stripes[stripe_idx]; + dis_u2s_dequeue_req(scratch.arena, thread, &key); + U64 slot_idx = key.u64[1]%dis_shared->slots_count; + U64 stripe_idx = slot_idx%dis_shared->stripes_count; + DIS_Slot *slot = &dis_shared->slots[slot_idx]; + DIS_Stripe *stripe = &dis_shared->stripes[stripe_idx]; //////////////////////////// //- rjf: grab next exe_path/query for this key @@ -371,15 +371,15 @@ fzy_search_thread__entry_point(void *p) B32 task_is_good = 0; Arena *task_arena = 0; String8 query = {0}; - FZY_Params params = {RDI_SectionKind_Procedures}; + DIS_Params params = {RDI_SectionKind_Procedures}; U64 initial_submit_gen = 0; OS_MutexScopeW(stripe->rw_mutex) { - for(FZY_Node *n = slot->first; n != 0; n = n->next) + for(DIS_Node *n = slot->first; n != 0; n = n->next) { if(u128_match(n->key, key)) { - FZY_Bucket *bucket = &n->buckets[n->submit_gen%ArrayCount(n->buckets)]; + DIS_Bucket *bucket = &n->buckets[n->submit_gen%ArrayCount(n->buckets)]; task_is_good = 1; initial_submit_gen = n->submit_gen; task_arena = bucket->arena; @@ -434,7 +434,7 @@ fzy_search_thread__entry_point(void *p) //////////////////////////// //- rjf: rdis * query * params -> item list // - FZY_ItemChunkList items_list = {0}; + DIS_ItemChunkList items_list = {0}; if(task_is_good) { U64 base_idx = 0; @@ -462,13 +462,13 @@ fzy_search_thread__entry_point(void *p) FuzzyMatchRangeList matches = fuzzy_match_find(task_arena, query, name); if(matches.count == matches.needle_part_count) { - FZY_ItemChunk *chunk = items_list.last; + DIS_ItemChunk *chunk = items_list.last; if(chunk == 0 || chunk->count >= chunk->cap) { - chunk = push_array(scratch.arena, FZY_ItemChunk, 1); + chunk = push_array(scratch.arena, DIS_ItemChunk, 1); chunk->cap = 1024; chunk->count = 0; - chunk->v = push_array_no_zero(scratch.arena, FZY_Item, chunk->cap); + chunk->v = push_array_no_zero(scratch.arena, DIS_Item, chunk->cap); SLLQueuePush(items_list.first, items_list.last, chunk); items_list.chunk_count += 1; } @@ -480,7 +480,7 @@ fzy_search_thread__entry_point(void *p) } if(idx%100 == 99) OS_MutexScopeR(stripe->rw_mutex) { - for(FZY_Node *n = slot->first; n != 0; n = n->next) + for(DIS_Node *n = slot->first; n != 0; n = n->next) { if(u128_match(n->key, key) && n->submit_gen > initial_submit_gen) { @@ -495,15 +495,15 @@ fzy_search_thread__entry_point(void *p) } //- rjf: item list -> item array - FZY_ItemArray items = {0}; + DIS_ItemArray items = {0}; if(task_is_good) { items.count = items_list.total_count; - items.v = push_array_no_zero(task_arena, FZY_Item, items.count); + items.v = push_array_no_zero(task_arena, DIS_Item, items.count); U64 idx = 0; - for(FZY_ItemChunk *chunk = items_list.first; chunk != 0; chunk = chunk->next) + for(DIS_ItemChunk *chunk = items_list.first; chunk != 0; chunk = chunk->next) { - MemoryCopy(items.v+idx, chunk->v, sizeof(FZY_Item)*chunk->count); + MemoryCopy(items.v+idx, chunk->v, sizeof(DIS_Item)*chunk->count); idx += chunk->count; } } @@ -511,7 +511,7 @@ fzy_search_thread__entry_point(void *p) //- rjf: sort item array if(items.count != 0 && query.size != 0) { - quick_sort(items.v, items.count, sizeof(FZY_Item), fzy_qsort_compare_items); + quick_sort(items.v, items.count, sizeof(DIS_Item), dis_qsort_compare_items); } //- rjf: commit to cache - busyloop on scope touches @@ -520,7 +520,7 @@ fzy_search_thread__entry_point(void *p) for(B32 done = 0; !done;) { B32 found = 0; - OS_MutexScopeW(stripe->rw_mutex) for(FZY_Node *n = slot->first; n != 0; n = n->next) + OS_MutexScopeW(stripe->rw_mutex) for(DIS_Node *n = slot->first; n != 0; n = n->next) { if(u128_match(n->key, key)) { diff --git a/src/dbgi_search/dbgi_search.h b/src/dbgi_search/dbgi_search.h new file mode 100644 index 00000000..3bcb9dee --- /dev/null +++ b/src/dbgi_search/dbgi_search.h @@ -0,0 +1,192 @@ +// Copyright (c) 2024 Epic Games Tools +// Licensed under the MIT license (https://opensource.org/license/mit/) + +#ifndef DBGI_SEARCH_H +#define DBGI_SEARCH_H + +//////////////////////////////// +//~ rjf: Result Types + +typedef struct DIS_Item DIS_Item; +struct DIS_Item +{ + U64 idx; // indexes into whole space of parameter tables. [rdis[0] element count) [rdis[1] element count) ... [rdis[n] element count) + U64 missed_size; + FuzzyMatchRangeList match_ranges; +}; + +typedef struct DIS_ItemChunk DIS_ItemChunk; +struct DIS_ItemChunk +{ + DIS_ItemChunk *next; + DIS_Item *v; + U64 count; + U64 cap; +}; + +typedef struct DIS_ItemChunkList DIS_ItemChunkList; +struct DIS_ItemChunkList +{ + DIS_ItemChunk *first; + DIS_ItemChunk *last; + U64 chunk_count; + U64 total_count; +}; + +typedef struct DIS_ItemArray DIS_ItemArray; +struct DIS_ItemArray +{ + DIS_Item *v; + U64 count; +}; + +//////////////////////////////// +//~ rjf: Search Parameter Types + +typedef struct DIS_Params DIS_Params; +struct DIS_Params +{ + RDI_SectionKind target; + DI_KeyArray dbgi_keys; +}; + +//////////////////////////////// +//~ rjf: Cache Types + +typedef struct DIS_Bucket DIS_Bucket; +struct DIS_Bucket +{ + Arena *arena; + String8 query; + DIS_Params params; + U64 params_hash; +}; + +typedef struct DIS_Node DIS_Node; +struct DIS_Node +{ + DIS_Node *next; + U128 key; + U64 touch_count; + U64 last_time_submitted_us; + DIS_Bucket buckets[3]; + U64 gen; + U64 submit_gen; + DIS_ItemArray gen_items; +}; + +typedef struct DIS_Slot DIS_Slot; +struct DIS_Slot +{ + DIS_Node *first; + DIS_Node *last; +}; + +typedef struct DIS_Stripe DIS_Stripe; +struct DIS_Stripe +{ + Arena *arena; + OS_Handle rw_mutex; + OS_Handle cv; +}; + +//////////////////////////////// +//~ rjf: Scoped Access Types + +typedef struct DIS_Touch DIS_Touch; +struct DIS_Touch +{ + DIS_Touch *next; + DIS_Node *node; +}; + +typedef struct DIS_Scope DIS_Scope; +struct DIS_Scope +{ + DIS_Scope *next; + DIS_Touch *first_touch; + DIS_Touch *last_touch; +}; + +typedef struct DIS_TCTX DIS_TCTX; +struct DIS_TCTX +{ + Arena *arena; + DIS_Scope *free_scope; + DIS_Touch *free_touch; +}; + +//////////////////////////////// +//~ rjf: Shared State Types + +typedef struct DIS_Thread DIS_Thread; +struct DIS_Thread +{ + OS_Handle thread; + OS_Handle u2f_ring_mutex; + OS_Handle u2f_ring_cv; + U64 u2f_ring_size; + U8 *u2f_ring_base; + U64 u2f_ring_write_pos; + U64 u2f_ring_read_pos; +}; + +typedef struct DIS_Shared DIS_Shared; +struct DIS_Shared +{ + Arena *arena; + + // rjf: search artifact cache table + U64 slots_count; + U64 stripes_count; + DIS_Slot *slots; + DIS_Stripe *stripes; + + // rjf: threads + U64 thread_count; + DIS_Thread *threads; +}; + +//////////////////////////////// +//~ rjf: Globals + +global DIS_Shared *dis_shared = 0; +thread_static DIS_TCTX *dis_tctx = 0; + +//////////////////////////////// +//~ rjf: Helpers + +internal U64 dis_hash_from_string(U64 seed, String8 string); +internal U64 dis_hash_from_params(DIS_Params *params); +internal U64 dis_item_num_from_array_element_idx__linear_search(DIS_ItemArray *array, U64 element_idx); +internal String8 dis_item_string_from_rdi_target_element_idx(RDI_Parsed *rdi, RDI_SectionKind target, U64 element_idx); +internal DIS_Params dis_params_copy(Arena *arena, DIS_Params *src); + +//////////////////////////////// +//~ rjf: Main Layer Initialization + +internal void dis_init(void); + +//////////////////////////////// +//~ rjf: Scope Functions + +internal DIS_Scope *dis_scope_open(void); +internal void dis_scope_close(DIS_Scope *scope); +internal void dis_scope_touch_node__stripe_mutex_r_guarded(DIS_Scope *scope, DIS_Node *node); + +//////////////////////////////// +//~ rjf: Cache Lookup Functions + +internal DIS_ItemArray dis_items_from_key_params_query(DIS_Scope *scope, U128 key, DIS_Params *params, String8 query, U64 endt_us, B32 *stale_out); + +//////////////////////////////// +//~ rjf: Searcher Threads + +internal B32 dis_u2s_enqueue_req(U128 key, U64 endt_us); +internal void dis_u2s_dequeue_req(Arena *arena, DIS_Thread *thread, U128 *key_out); + +internal int dis_qsort_compare_items(DIS_Item *a, DIS_Item *b); + +internal void dis_search_thread__entry_point(void *p); + +#endif // DBGI_SEARCH_H diff --git a/src/fuzzy_search/fuzzy_search.h b/src/fuzzy_search/fuzzy_search.h deleted file mode 100644 index 00a379b9..00000000 --- a/src/fuzzy_search/fuzzy_search.h +++ /dev/null @@ -1,192 +0,0 @@ -// Copyright (c) 2024 Epic Games Tools -// Licensed under the MIT license (https://opensource.org/license/mit/) - -#ifndef FUZZY_SEARCH_H -#define FUZZY_SEARCH_H - -//////////////////////////////// -//~ rjf: Result Types - -typedef struct FZY_Item FZY_Item; -struct FZY_Item -{ - U64 idx; // indexes into whole space of parameter tables. [rdis[0] element count) [rdis[1] element count) ... [rdis[n] element count) - U64 missed_size; - FuzzyMatchRangeList match_ranges; -}; - -typedef struct FZY_ItemChunk FZY_ItemChunk; -struct FZY_ItemChunk -{ - FZY_ItemChunk *next; - FZY_Item *v; - U64 count; - U64 cap; -}; - -typedef struct FZY_ItemChunkList FZY_ItemChunkList; -struct FZY_ItemChunkList -{ - FZY_ItemChunk *first; - FZY_ItemChunk *last; - U64 chunk_count; - U64 total_count; -}; - -typedef struct FZY_ItemArray FZY_ItemArray; -struct FZY_ItemArray -{ - FZY_Item *v; - U64 count; -}; - -//////////////////////////////// -//~ rjf: Search Parameter Types - -typedef struct FZY_Params FZY_Params; -struct FZY_Params -{ - RDI_SectionKind target; - DI_KeyArray dbgi_keys; -}; - -//////////////////////////////// -//~ rjf: Cache Types - -typedef struct FZY_Bucket FZY_Bucket; -struct FZY_Bucket -{ - Arena *arena; - String8 query; - FZY_Params params; - U64 params_hash; -}; - -typedef struct FZY_Node FZY_Node; -struct FZY_Node -{ - FZY_Node *next; - U128 key; - U64 touch_count; - U64 last_time_submitted_us; - FZY_Bucket buckets[3]; - U64 gen; - U64 submit_gen; - FZY_ItemArray gen_items; -}; - -typedef struct FZY_Slot FZY_Slot; -struct FZY_Slot -{ - FZY_Node *first; - FZY_Node *last; -}; - -typedef struct FZY_Stripe FZY_Stripe; -struct FZY_Stripe -{ - Arena *arena; - OS_Handle rw_mutex; - OS_Handle cv; -}; - -//////////////////////////////// -//~ rjf: Scoped Access Types - -typedef struct FZY_Touch FZY_Touch; -struct FZY_Touch -{ - FZY_Touch *next; - FZY_Node *node; -}; - -typedef struct FZY_Scope FZY_Scope; -struct FZY_Scope -{ - FZY_Scope *next; - FZY_Touch *first_touch; - FZY_Touch *last_touch; -}; - -typedef struct FZY_TCTX FZY_TCTX; -struct FZY_TCTX -{ - Arena *arena; - FZY_Scope *free_scope; - FZY_Touch *free_touch; -}; - -//////////////////////////////// -//~ rjf: Shared State Types - -typedef struct FZY_Thread FZY_Thread; -struct FZY_Thread -{ - OS_Handle thread; - OS_Handle u2f_ring_mutex; - OS_Handle u2f_ring_cv; - U64 u2f_ring_size; - U8 *u2f_ring_base; - U64 u2f_ring_write_pos; - U64 u2f_ring_read_pos; -}; - -typedef struct FZY_Shared FZY_Shared; -struct FZY_Shared -{ - Arena *arena; - - // rjf: search artifact cache table - U64 slots_count; - U64 stripes_count; - FZY_Slot *slots; - FZY_Stripe *stripes; - - // rjf: threads - U64 thread_count; - FZY_Thread *threads; -}; - -//////////////////////////////// -//~ rjf: Globals - -global FZY_Shared *fzy_shared = 0; -thread_static FZY_TCTX *fzy_tctx = 0; - -//////////////////////////////// -//~ rjf: Helpers - -internal U64 fzy_hash_from_string(U64 seed, String8 string); -internal U64 fzy_hash_from_params(FZY_Params *params); -internal U64 fzy_item_num_from_array_element_idx__linear_search(FZY_ItemArray *array, U64 element_idx); -internal String8 fzy_item_string_from_rdi_target_element_idx(RDI_Parsed *rdi, RDI_SectionKind target, U64 element_idx); -internal FZY_Params fzy_params_copy(Arena *arena, FZY_Params *src); - -//////////////////////////////// -//~ rjf: Main Layer Initialization - -internal void fzy_init(void); - -//////////////////////////////// -//~ rjf: Scope Functions - -internal FZY_Scope *fzy_scope_open(void); -internal void fzy_scope_close(FZY_Scope *scope); -internal void fzy_scope_touch_node__stripe_mutex_r_guarded(FZY_Scope *scope, FZY_Node *node); - -//////////////////////////////// -//~ rjf: Cache Lookup Functions - -internal FZY_ItemArray fzy_items_from_key_params_query(FZY_Scope *scope, U128 key, FZY_Params *params, String8 query, U64 endt_us, B32 *stale_out); - -//////////////////////////////// -//~ rjf: Searcher Threads - -internal B32 fzy_u2s_enqueue_req(U128 key, U64 endt_us); -internal void fzy_u2s_dequeue_req(Arena *arena, FZY_Thread *thread, U128 *key_out); - -internal int fzy_qsort_compare_items(FZY_Item *a, FZY_Item *b); - -internal void fzy_search_thread__entry_point(void *p); - -#endif // FUZZY_SEARCH_H diff --git a/src/geo_cache/geo_cache.c b/src/geo_cache/geo_cache.c index 81cd10a7..4e0dcd28 100644 --- a/src/geo_cache/geo_cache.c +++ b/src/geo_cache/geo_cache.c @@ -42,21 +42,6 @@ geo_tctx_ensure_inited(void) } } -//////////////////////////////// -//~ rjf: User Clock - -internal void -geo_user_clock_tick(void) -{ - ins_atomic_u64_inc_eval(&geo_shared->user_clock_idx); -} - -internal U64 -geo_user_clock_idx(void) -{ - return ins_atomic_u64_eval(&geo_shared->user_clock_idx); -} - //////////////////////////////// //~ rjf: Scoped Access @@ -110,7 +95,7 @@ geo_scope_touch_node__stripe_r_guarded(GEO_Scope *scope, GEO_Node *node) GEO_Touch *touch = geo_tctx->free_touch; ins_atomic_u64_inc_eval(&node->scope_ref_count); ins_atomic_u64_eval_assign(&node->last_time_touched_us, os_now_microseconds()); - ins_atomic_u64_eval_assign(&node->last_user_clock_idx_touched, geo_user_clock_idx()); + ins_atomic_u64_eval_assign(&node->last_user_clock_idx_touched, update_tick_idx()); if(touch != 0) { SLLStackPop(geo_tctx->free_touch); @@ -325,7 +310,7 @@ geo_evictor_thread__entry_point(void *p) for(;;) { U64 check_time_us = os_now_microseconds(); - U64 check_time_user_clocks = geo_user_clock_idx(); + U64 check_time_user_clocks = update_tick_idx(); U64 evict_threshold_us = 10*1000000; U64 evict_threshold_user_clocks = 10; for(U64 slot_idx = 0; slot_idx < geo_shared->slots_count; slot_idx += 1) diff --git a/src/geo_cache/geo_cache.h b/src/geo_cache/geo_cache.h index a86c86cf..230d059e 100644 --- a/src/geo_cache/geo_cache.h +++ b/src/geo_cache/geo_cache.h @@ -72,9 +72,6 @@ struct GEO_Shared { Arena *arena; - // rjf: user clock - U64 user_clock_idx; - // rjf: cache U64 slots_count; U64 stripes_count; @@ -110,12 +107,6 @@ internal void geo_init(void); internal void geo_tctx_ensure_inited(void); -//////////////////////////////// -//~ rjf: User Clock - -internal void geo_user_clock_tick(void); -internal U64 geo_user_clock_idx(void); - //////////////////////////////// //~ rjf: Scoped Access diff --git a/src/raddbg/raddbg_core.c b/src/raddbg/raddbg_core.c index ae643ffa..53c92580 100644 --- a/src/raddbg/raddbg_core.c +++ b/src/raddbg/raddbg_core.c @@ -4880,7 +4880,7 @@ rd_window_frame(RD_Window *ws) { Temp scratch = scratch_begin(0, 0); DI_Scope *di_scope = di_scope_open(); - FZY_Scope *fzy_scope = fzy_scope_open(); + DIS_Scope *dis_scope = dis_scope_open(); DI_KeyList dbgi_keys_list = d_push_active_dbgi_key_list(scratch.arena); DI_KeyArray dbgi_keys = di_key_array_from_list(scratch.arena, &dbgi_keys_list); @@ -5012,14 +5012,14 @@ rd_window_frame(RD_Window *ws) //- rjf: gather globals if(ws->autocomp_lister_params.flags & RD_AutoCompListerFlag_Globals && query_word.size != 0) { - U128 fzy_key = {d_hash_from_string(str8_lit("autocomp_globals_fzy_key"))}; - FZY_Params fzy_params = + U128 dis_key = {d_hash_from_string(str8_lit("autocomp_globals_dis_key"))}; + DIS_Params dis_params = { RDI_SectionKind_GlobalVariables, dbgi_keys, }; B32 is_stale = 0; - FZY_ItemArray items = fzy_items_from_key_params_query(fzy_scope, fzy_key, &fzy_params, query_word, 0, &is_stale); + DIS_ItemArray items = dis_items_from_key_params_query(dis_scope, dis_key, &dis_params, query_word, 0, &is_stale); for(U64 idx = 0; idx < 20 && idx < items.count; idx += 1) { // rjf: determine dbgi/rdi to which this item belongs @@ -5030,7 +5030,7 @@ rd_window_frame(RD_Window *ws) for(U64 rdi_idx = 0; rdi_idx < rdis_count; rdi_idx += 1) { U64 table_count = 0; - rdi_section_raw_table_from_kind(rdis[rdi_idx], fzy_params.target, &table_count); + rdi_section_raw_table_from_kind(rdis[rdi_idx], dis_params.target, &table_count); if(base_idx <= items.v[idx].idx && items.v[idx].idx < base_idx + table_count) { dbgi_key = dbgi_keys.v[rdi_idx]; @@ -5042,7 +5042,7 @@ rd_window_frame(RD_Window *ws) } // rjf: unpack info - String8 name = fzy_item_string_from_rdi_target_element_idx(rdi, fzy_params.target, items.v[idx].idx-base_idx); + String8 name = dis_item_string_from_rdi_target_element_idx(rdi, dis_params.target, items.v[idx].idx-base_idx); // rjf: push item RD_AutoCompListerItem item = {0}; @@ -5059,14 +5059,14 @@ rd_window_frame(RD_Window *ws) //- rjf: gather thread locals if(ws->autocomp_lister_params.flags & RD_AutoCompListerFlag_ThreadLocals && query_word.size != 0) { - U128 fzy_key = {d_hash_from_string(str8_lit("autocomp_tvars_fzy_key"))}; - FZY_Params fzy_params = + U128 dis_key = {d_hash_from_string(str8_lit("autocomp_tvars_dis_key"))}; + DIS_Params dis_params = { RDI_SectionKind_ThreadVariables, dbgi_keys, }; B32 is_stale = 0; - FZY_ItemArray items = fzy_items_from_key_params_query(fzy_scope, fzy_key, &fzy_params, query_word, 0, &is_stale); + DIS_ItemArray items = dis_items_from_key_params_query(dis_scope, dis_key, &dis_params, query_word, 0, &is_stale); for(U64 idx = 0; idx < 20 && idx < items.count; idx += 1) { // rjf: determine dbgi/rdi to which this item belongs @@ -5077,7 +5077,7 @@ rd_window_frame(RD_Window *ws) for(U64 rdi_idx = 0; rdi_idx < rdis_count; rdi_idx += 1) { U64 table_count = 0; - rdi_section_raw_table_from_kind(rdis[rdi_idx], fzy_params.target, &table_count); + rdi_section_raw_table_from_kind(rdis[rdi_idx], dis_params.target, &table_count); if(base_idx <= items.v[idx].idx && items.v[idx].idx < base_idx + table_count) { dbgi_key = dbgi_keys.v[rdi_idx]; @@ -5089,7 +5089,7 @@ rd_window_frame(RD_Window *ws) } // rjf: unpack info - String8 name = fzy_item_string_from_rdi_target_element_idx(rdi, fzy_params.target, items.v[idx].idx-base_idx); + String8 name = dis_item_string_from_rdi_target_element_idx(rdi, dis_params.target, items.v[idx].idx-base_idx); // rjf: push item RD_AutoCompListerItem item = {0}; @@ -5106,14 +5106,14 @@ rd_window_frame(RD_Window *ws) //- rjf: gather procedures if(ws->autocomp_lister_params.flags & RD_AutoCompListerFlag_Procedures && query_word.size != 0) { - U128 fzy_key = {d_hash_from_string(str8_lit("autocomp_procedures_fzy_key"))}; - FZY_Params fzy_params = + U128 dis_key = {d_hash_from_string(str8_lit("autocomp_procedures_dis_key"))}; + DIS_Params dis_params = { RDI_SectionKind_Procedures, dbgi_keys, }; B32 is_stale = 0; - FZY_ItemArray items = fzy_items_from_key_params_query(fzy_scope, fzy_key, &fzy_params, query_word, 0, &is_stale); + DIS_ItemArray items = dis_items_from_key_params_query(dis_scope, dis_key, &dis_params, query_word, 0, &is_stale); for(U64 idx = 0; idx < 20 && idx < items.count; idx += 1) { // rjf: determine dbgi/rdi to which this item belongs @@ -5124,7 +5124,7 @@ rd_window_frame(RD_Window *ws) for(U64 rdi_idx = 0; rdi_idx < rdis_count; rdi_idx += 1) { U64 table_count = 0; - rdi_section_raw_table_from_kind(rdis[rdi_idx], fzy_params.target, &table_count); + rdi_section_raw_table_from_kind(rdis[rdi_idx], dis_params.target, &table_count); if(base_idx <= items.v[idx].idx && items.v[idx].idx < base_idx + table_count) { dbgi_key = dbgi_keys.v[rdi_idx]; @@ -5136,7 +5136,7 @@ rd_window_frame(RD_Window *ws) } // rjf: unpack info - String8 name = fzy_item_string_from_rdi_target_element_idx(rdi, fzy_params.target, items.v[idx].idx-base_idx); + String8 name = dis_item_string_from_rdi_target_element_idx(rdi, dis_params.target, items.v[idx].idx-base_idx); // rjf: push item RD_AutoCompListerItem item = {0}; @@ -5153,14 +5153,14 @@ rd_window_frame(RD_Window *ws) //- rjf: gather types if(ws->autocomp_lister_params.flags & RD_AutoCompListerFlag_Types && query_word.size != 0) { - U128 fzy_key = {d_hash_from_string(str8_lit("autocomp_types_fzy_key"))}; - FZY_Params fzy_params = + U128 dis_key = {d_hash_from_string(str8_lit("autocomp_types_dis_key"))}; + DIS_Params dis_params = { RDI_SectionKind_UDTs, dbgi_keys, }; B32 is_stale = 0; - FZY_ItemArray items = fzy_items_from_key_params_query(fzy_scope, fzy_key, &fzy_params, query_word, 0, &is_stale); + DIS_ItemArray items = dis_items_from_key_params_query(dis_scope, dis_key, &dis_params, query_word, 0, &is_stale); for(U64 idx = 0; idx < 20 && idx < items.count; idx += 1) { // rjf: determine dbgi/rdi to which this item belongs @@ -5171,7 +5171,7 @@ rd_window_frame(RD_Window *ws) for(U64 rdi_idx = 0; rdi_idx < rdis_count; rdi_idx += 1) { U64 table_count = 0; - rdi_section_raw_table_from_kind(rdis[rdi_idx], fzy_params.target, &table_count); + rdi_section_raw_table_from_kind(rdis[rdi_idx], dis_params.target, &table_count); if(base_idx <= items.v[idx].idx && items.v[idx].idx < base_idx + table_count) { dbgi_key = dbgi_keys.v[rdi_idx]; @@ -5183,7 +5183,7 @@ rd_window_frame(RD_Window *ws) } // rjf: unpack info - String8 name = fzy_item_string_from_rdi_target_element_idx(rdi, fzy_params.target, items.v[idx].idx-base_idx); + String8 name = dis_item_string_from_rdi_target_element_idx(rdi, dis_params.target, items.v[idx].idx-base_idx); // rjf: push item RD_AutoCompListerItem item = {0}; @@ -5467,7 +5467,7 @@ rd_window_frame(RD_Window *ws) } } - fzy_scope_close(fzy_scope); + dis_scope_close(dis_scope); di_scope_close(di_scope); scratch_end(scratch); } @@ -9323,7 +9323,7 @@ rd_ev_view_rule_expr_num_from_id__meta_ctrl_entities(U64 id, void *user_data, CT typedef struct RD_DebugInfoTableExpandAccel RD_DebugInfoTableExpandAccel; struct RD_DebugInfoTableExpandAccel { - FZY_ItemArray items; + DIS_ItemArray items; }; internal EV_ExpandInfo @@ -9348,8 +9348,8 @@ rd_ev_view_rule_expr_expand_info__debug_info_tables(Arena *arena, EV_View *view, //- rjf: query all filtered items from dbgi searching system U128 fuzzy_search_key = {(U64)view, (U64)section}; B32 items_stale = 0; - FZY_Params params = {section, dbgi_keys}; - accel->items = fzy_items_from_key_params_query(rd_state->frame_fzy_scope, fuzzy_search_key, ¶ms, filter, endt_us, &items_stale); + DIS_Params params = {section, dbgi_keys}; + accel->items = dis_items_from_key_params_query(rd_state->frame_dis_scope, fuzzy_search_key, ¶ms, filter, endt_us, &items_stale); if(items_stale) { rd_request_frame(); @@ -9376,7 +9376,7 @@ rd_ev_view_rule_expr_expand_range_info__debug_info_tables(Arena *arena, EV_View for EachIndex(row_expr_idx, result.row_exprs_count) { // rjf: unpack row info - FZY_Item *item = &accel->items.v[idx_range.min + row_expr_idx]; + DIS_Item *item = &accel->items.v[idx_range.min + row_expr_idx]; // rjf: determine module to which this item belongs E_Module *module = e_parse_ctx->primary_module; @@ -9488,7 +9488,7 @@ internal U64 rd_ev_view_rule_expr_num_from_id__debug_info_tables(U64 id, void *user_data, RDI_SectionKind section) { RD_DebugInfoTableExpandAccel *accel = (RD_DebugInfoTableExpandAccel *)user_data; - U64 num = fzy_item_num_from_array_element_idx__linear_search(&accel->items, id-1); + U64 num = dis_item_num_from_array_element_idx__linear_search(&accel->items, id-1); return num; } @@ -11704,7 +11704,7 @@ rd_frame(void) if(depth == 0) { rd_state->frame_di_scope = di_scope_open(); - rd_state->frame_fzy_scope = fzy_scope_open(); + rd_state->frame_dis_scope = dis_scope_open(); } B32 allow_text_hotkeys = !rd_state->text_edit_mode; rd_state->text_edit_mode = 0; @@ -16739,7 +16739,7 @@ rd_frame(void) if(depth == 0) { di_scope_close(rd_state->frame_di_scope); - fzy_scope_close(rd_state->frame_fzy_scope); + dis_scope_close(rd_state->frame_dis_scope); } ////////////////////////////// diff --git a/src/raddbg/raddbg_core.h b/src/raddbg/raddbg_core.h index ed10ed8c..8181dcd3 100644 --- a/src/raddbg/raddbg_core.h +++ b/src/raddbg/raddbg_core.h @@ -822,7 +822,7 @@ struct RD_State // rjf: frame parameters F32 frame_dt; DI_Scope *frame_di_scope; - FZY_Scope *frame_fzy_scope; + DIS_Scope *frame_dis_scope; // rjf: ambiguous path table U64 ambiguous_path_slots_count; diff --git a/src/raddbg/raddbg_main.c b/src/raddbg/raddbg_main.c index 366127aa..3da33155 100644 --- a/src/raddbg/raddbg_main.c +++ b/src/raddbg/raddbg_main.c @@ -595,8 +595,8 @@ #include "regs/regs.h" #include "regs/rdi/regs_rdi.h" #include "dbgi/dbgi.h" +#include "dbgi_search/dbgi_search.h" #include "dasm_cache/dasm_cache.h" -#include "fuzzy_search/fuzzy_search.h" #include "demon/demon_inc.h" #include "eval/eval_inc.h" #include "eval_visualization/eval_visualization_inc.h" @@ -637,8 +637,8 @@ #include "regs/regs.c" #include "regs/rdi/regs_rdi.c" #include "dbgi/dbgi.c" +#include "dbgi_search/dbgi_search.c" #include "dasm_cache/dasm_cache.c" -#include "fuzzy_search/fuzzy_search.c" #include "demon/demon_inc.c" #include "eval/eval_inc.c" #include "eval_visualization/eval_visualization_inc.c" @@ -693,6 +693,7 @@ global OS_Handle ipc_s2m_ring_cv = {0}; internal void ipc_signaler_thread__entry_point(void *p) { + ThreadNameF("[rd] ipc signaler thread"); for(;;) { if(os_semaphore_take(ipc_signal_semaphore, max_U64)) diff --git a/src/raddbg/raddbg_views.c b/src/raddbg/raddbg_views.c index 6d9b7534..696cb4d4 100644 --- a/src/raddbg/raddbg_views.c +++ b/src/raddbg/raddbg_views.c @@ -1264,7 +1264,7 @@ rd_watch_view_build(RD_WatchViewState *ewv, RD_WatchViewFlags flags, String8 roo { ProfBeginFunction(); DI_Scope *di_scope = di_scope_open(); - FZY_Scope *fzy_scope = fzy_scope_open(); + DIS_Scope *dis_scope = dis_scope_open(); Temp scratch = scratch_begin(0, 0); UI_ScrollPt2 scroll_pos = rd_view_scroll_pos(); F32 entity_hover_t_rate = rd_setting_val_from_code(RD_SettingCode_HoverAnimations).s32 ? (1 - pow_f32(2, (-20.f * rd_state->frame_dt))) : 1.f; @@ -3407,7 +3407,7 @@ rd_watch_view_build(RD_WatchViewState *ewv, RD_WatchViewFlags flags, String8 roo if(!is_top_level_hook) { rd_store_view_scroll_pos(scroll_pos); } scratch_end(scratch); - fzy_scope_close(fzy_scope); + dis_scope_close(dis_scope); di_scope_close(di_scope); ProfEnd(); } @@ -5214,11 +5214,11 @@ RD_VIEW_RULE_UI_FUNCTION_DEF(symbol_lister) ProfBeginFunction(); Temp scratch = scratch_begin(0, 0); DI_Scope *di_scope = di_scope_open(); - FZY_Scope *fzy_scope = fzy_scope_open(); + DIS_Scope *dis_scope = dis_scope_open(); F32 row_height_px = floor_f32(ui_top_font_size()*2.5f); DI_KeyList dbgi_keys_list = d_push_active_dbgi_key_list(scratch.arena); DI_KeyArray dbgi_keys = di_key_array_from_list(scratch.arena, &dbgi_keys_list); - FZY_Params fuzzy_search_params = {RDI_SectionKind_Procedures, dbgi_keys}; + DIS_Params fuzzy_search_params = {RDI_SectionKind_Procedures, dbgi_keys}; U64 endt_us = os_now_microseconds()+200; //- rjf: grab rdis @@ -5245,7 +5245,7 @@ RD_VIEW_RULE_UI_FUNCTION_DEF(symbol_lister) //- rjf: query -> raddbg, filtered items U128 fuzzy_search_key = {rd_regs()->view.u64[0], rd_regs()->view.u64[1]}; B32 items_stale = 0; - FZY_ItemArray items = fzy_items_from_key_params_query(fzy_scope, fuzzy_search_key, &fuzzy_search_params, string, endt_us, &items_stale); + DIS_ItemArray items = dis_items_from_key_params_query(dis_scope, fuzzy_search_key, &fuzzy_search_params, string, endt_us, &items_stale); if(items_stale) { rd_request_frame(); @@ -5254,7 +5254,7 @@ RD_VIEW_RULE_UI_FUNCTION_DEF(symbol_lister) //- rjf: submit best match when hitting enter w/ no selection if(slv->cursor.y == 0 && items.count != 0 && ui_slot_press(UI_EventActionSlot_Accept)) { - FZY_Item *item = &items.v[0]; + DIS_Item *item = &items.v[0]; U64 base_idx = 0; for(U64 rdi_idx = 0; rdi_idx < rdis_count; rdi_idx += 1) { @@ -5306,7 +5306,7 @@ RD_VIEW_RULE_UI_FUNCTION_DEF(symbol_lister) idx += 1) UI_Focus((slv->cursor.y == idx+1) ? UI_FocusKind_On : UI_FocusKind_Off) { - FZY_Item *item = &items.v[idx]; + DIS_Item *item = &items.v[idx]; //- rjf: determine dbgi/rdi to which this item belongs DI_Key dbgi_key = {0}; @@ -5385,7 +5385,7 @@ RD_VIEW_RULE_UI_FUNCTION_DEF(symbol_lister) } rd_store_view_scroll_pos(scroll_pos); - fzy_scope_close(fzy_scope); + dis_scope_close(dis_scope); di_scope_close(di_scope); scratch_end(scratch); ProfEnd(); diff --git a/src/text_cache/text_cache.c b/src/text_cache/text_cache.c index 3501dab1..fff5ddc0 100644 --- a/src/text_cache/text_cache.c +++ b/src/text_cache/text_cache.c @@ -1628,21 +1628,6 @@ txt_tctx_ensure_inited(void) } } -//////////////////////////////// -//~ rjf: User Clock - -internal void -txt_user_clock_tick(void) -{ - ins_atomic_u64_inc_eval(&txt_shared->user_clock_idx); -} - -internal U64 -txt_user_clock_idx(void) -{ - return ins_atomic_u64_eval(&txt_shared->user_clock_idx); -} - //////////////////////////////// //~ rjf: Scoped Access @@ -1696,7 +1681,7 @@ txt_scope_touch_node__stripe_r_guarded(TXT_Scope *scope, TXT_Node *node) TXT_Touch *touch = txt_tctx->free_touch; ins_atomic_u64_inc_eval(&node->scope_ref_count); ins_atomic_u64_eval_assign(&node->last_time_touched_us, os_now_microseconds()); - ins_atomic_u64_eval_assign(&node->last_user_clock_idx_touched, txt_user_clock_idx()); + ins_atomic_u64_eval_assign(&node->last_user_clock_idx_touched, update_tick_idx()); if(touch != 0) { SLLStackPop(txt_tctx->free_touch); @@ -2351,7 +2336,7 @@ txt_evictor_thread__entry_point(void *p) for(;;) { U64 check_time_us = os_now_microseconds(); - U64 check_time_user_clocks = txt_user_clock_idx(); + U64 check_time_user_clocks = update_tick_idx(); U64 evict_threshold_us = 10*1000000; U64 evict_threshold_user_clocks = 10; for(U64 slot_idx = 0; slot_idx < txt_shared->slots_count; slot_idx += 1) diff --git a/src/text_cache/text_cache.h b/src/text_cache/text_cache.h index ea4032f3..2311139e 100644 --- a/src/text_cache/text_cache.h +++ b/src/text_cache/text_cache.h @@ -263,12 +263,6 @@ internal void txt_init(void); internal void txt_tctx_ensure_inited(void); -//////////////////////////////// -//~ rjf: User Clock - -internal void txt_user_clock_tick(void); -internal U64 txt_user_clock_idx(void); - //////////////////////////////// //~ rjf: Scoped Access diff --git a/src/texture_cache/texture_cache.c b/src/texture_cache/texture_cache.c index 20af85f3..11a2bbaf 100644 --- a/src/texture_cache/texture_cache.c +++ b/src/texture_cache/texture_cache.c @@ -55,21 +55,6 @@ tex_tctx_ensure_inited(void) } } -//////////////////////////////// -//~ rjf: User Clock - -internal void -tex_user_clock_tick(void) -{ - ins_atomic_u64_inc_eval(&tex_shared->user_clock_idx); -} - -internal U64 -tex_user_clock_idx(void) -{ - return ins_atomic_u64_eval(&tex_shared->user_clock_idx); -} - //////////////////////////////// //~ rjf: Scoped Access @@ -123,7 +108,7 @@ tex_scope_touch_node__stripe_r_guarded(TEX_Scope *scope, TEX_Node *node) TEX_Touch *touch = tex_tctx->free_touch; ins_atomic_u64_inc_eval(&node->scope_ref_count); ins_atomic_u64_eval_assign(&node->last_time_touched_us, os_now_microseconds()); - ins_atomic_u64_eval_assign(&node->last_user_clock_idx_touched, tex_user_clock_idx()); + ins_atomic_u64_eval_assign(&node->last_user_clock_idx_touched, update_tick_idx()); if(touch != 0) { SLLStackPop(tex_tctx->free_touch); @@ -347,7 +332,7 @@ tex_evictor_thread__entry_point(void *p) for(;;) { U64 check_time_us = os_now_microseconds(); - U64 check_time_user_clocks = tex_user_clock_idx(); + U64 check_time_user_clocks = update_tick_idx(); U64 evict_threshold_us = 10*1000000; U64 evict_threshold_user_clocks = 10; for(U64 slot_idx = 0; slot_idx < tex_shared->slots_count; slot_idx += 1) diff --git a/src/texture_cache/texture_cache.h b/src/texture_cache/texture_cache.h index fbd04e8f..617618dd 100644 --- a/src/texture_cache/texture_cache.h +++ b/src/texture_cache/texture_cache.h @@ -84,9 +84,6 @@ struct TEX_Shared { Arena *arena; - // rjf: user clock - U64 user_clock_idx; - // rjf: cache U64 slots_count; U64 stripes_count; @@ -127,12 +124,6 @@ internal void tex_init(void); internal void tex_tctx_ensure_inited(void); -//////////////////////////////// -//~ rjf: User Clock - -internal void tex_user_clock_tick(void); -internal U64 tex_user_clock_idx(void); - //////////////////////////////// //~ rjf: Scoped Access