fix more tab bar stuff; further sketchout of asynchronous dbgi layer fuzzy searching

This commit is contained in:
Ryan Fleury
2024-01-30 09:57:15 -08:00
parent d139c2874c
commit 4ef814acb5
5 changed files with 190 additions and 113 deletions
+53 -4
View File
@@ -189,6 +189,12 @@ dbgi_scope_touch_binary__stripe_mutex_r_guarded(DBGI_Scope *scope, DBGI_Binary *
SLLQueuePush(scope->first_tb, scope->last_tb, tb);
}
internal void
dbgi_scope_touch_fuzzy_search__stripe_mutex_r_guarded(DBGI_Scope *scope, DBGI_FuzzySearchNode *node)
{
}
////////////////////////////////
//~ rjf: Binary Cache Functions
@@ -339,10 +345,11 @@ dbgi_parse_from_exe_path(DBGI_Scope *scope, String8 exe_path, U64 endt_us)
////////////////////////////////
//~ rjf: Fuzzy Search Cache Functions
internal DBGI_FuzzySearchResult *
dbgi_fuzzy_search_result_from_key_exe_query(U128 key, String8 exe_path, String8 query, U64 endt_us)
internal DBGI_FuzzySearchItemArray
dbgi_fuzzy_search_items_from_key_exe_query(DBGI_Scope *scope, U128 key, String8 exe_path, String8 query, U64 endt_us)
{
DBGI_FuzzySearchResult *result = &dbgi_fuzzy_search_result_nil;
DBGI_FuzzySearchItemArray items = {0};
#if 0
{
U64 slot_idx = key.u64[1]%dbgi_shared->fuzzy_search_slots_count;
U64 stripe_idx = slot_idx%dbgi_shared->fuzzy_search_stripes_count;
@@ -363,10 +370,31 @@ dbgi_fuzzy_search_result_from_key_exe_query(U128 key, String8 exe_path, String8
{
node = push_array(stripe->arena, DBGI_FuzzySearchNode, 1);
DLLPushBack(slot->first, slot->last, node);
node->key = key;
}
B32 stale = 1;
if(node->gen > 0)
{
U64 v_idx = (node->gen-1)%ArrayCount(node->v);
if(str8_match(exe_path, node->v[v_idx].exe_path, 0))
{
items = node->v[v_idx].items;
stale = str8_match(query, node->v[v_idx].query, 0);
}
}
if(stale && node->submitted != 0) OS_MutexScopeRWPromote(stripe->rw_mutex)
{
node->submitted = (U64)!!dbgi_u2f_enqueue_req(key, exe_path, query, endt_us);
}
if(!stale || os_now_microseconds() >= endt_us)
{
break;
}
os_condition_variable_wait_rw_r(stripe->cv, stripe->rw_mutex, endt_us);
}
}
return result;
#endif
return items;
}
////////////////////////////////
@@ -930,3 +958,24 @@ dbgi_parse_thread_entry_point(void *p)
scratch_end(scratch);
}
}
////////////////////////////////
//~ rjf: Fuzzy Searching Threads
internal B32
dbgi_u2f_enqueue_req(U128 key, String8 exe_path, String8 query, U64 endt_us)
{
return 0;
}
internal void
dbgi_u2f_dequeue_req(Arena *arena, U128 *key_out, String8 *exe_path_out, String8 *query_out)
{
}
internal void
dbgi_fuzzy_thread__entry_point(void *p)
{
}
+79 -65
View File
@@ -97,67 +97,6 @@ struct DBGI_BinaryStripe
OS_Handle cv;
};
////////////////////////////////
//~ rjf: Weak Access Scope Types
typedef struct DBGI_TouchedBinary DBGI_TouchedBinary;
struct DBGI_TouchedBinary
{
DBGI_TouchedBinary *next;
DBGI_Binary *binary;
};
typedef struct DBGI_Scope DBGI_Scope;
struct DBGI_Scope
{
DBGI_Scope *next;
DBGI_TouchedBinary *first_tb;
DBGI_TouchedBinary *last_tb;
};
typedef struct DBGI_ThreadCtx DBGI_ThreadCtx;
struct DBGI_ThreadCtx
{
Arena *arena;
DBGI_Scope *free_scope;
DBGI_TouchedBinary *free_tb;
};
////////////////////////////////
//~ rjf: Event Types
typedef enum DBGI_EventKind
{
DBGI_EventKind_Null,
DBGI_EventKind_ConversionStarted,
DBGI_EventKind_ConversionEnded,
DBGI_EventKind_ConversionFailureUnsupportedFormat,
DBGI_EventKind_COUNT
}
DBGI_EventKind;
typedef struct DBGI_Event DBGI_Event;
struct DBGI_Event
{
DBGI_EventKind kind;
String8 string;
};
typedef struct DBGI_EventNode DBGI_EventNode;
struct DBGI_EventNode
{
DBGI_EventNode *next;
DBGI_Event v;
};
typedef struct DBGI_EventList DBGI_EventList;
struct DBGI_EventList
{
DBGI_EventNode *first;
DBGI_EventNode *last;
U64 count;
};
////////////////////////////////
//~ rjf: Fuzzy Search Cache Types
@@ -195,6 +134,9 @@ struct DBGI_FuzzySearchItemArray
typedef struct DBGI_FuzzySearchResult DBGI_FuzzySearchResult;
struct DBGI_FuzzySearchResult
{
Arena *arena;
String8 exe_path;
String8 query;
DBGI_FuzzySearchItemArray items;
};
@@ -203,8 +145,9 @@ struct DBGI_FuzzySearchNode
{
DBGI_FuzzySearchNode *next;
DBGI_FuzzySearchNode *prev;
Arena *arena;
U128 key;
U64 submitted;
U64 scope_touch_count;
U64 gen;
DBGI_FuzzySearchResult v[2];
};
@@ -224,6 +167,77 @@ struct DBGI_FuzzySearchStripe
OS_Handle cv;
};
////////////////////////////////
//~ rjf: Weak Access Scope Types
typedef struct DBGI_TouchedBinary DBGI_TouchedBinary;
struct DBGI_TouchedBinary
{
DBGI_TouchedBinary *next;
DBGI_Binary *binary;
};
typedef struct DBGI_TouchedFuzzySearch DBGI_TouchedFuzzySearch;
struct DBGI_TouchedFuzzySearch
{
DBGI_TouchedFuzzySearch *next;
DBGI_FuzzySearchNode *node;
};
typedef struct DBGI_Scope DBGI_Scope;
struct DBGI_Scope
{
DBGI_Scope *next;
DBGI_TouchedBinary *first_tb;
DBGI_TouchedBinary *last_tb;
DBGI_TouchedFuzzySearch *first_tfs;
DBGI_TouchedFuzzySearch *last_tfs;
};
typedef struct DBGI_ThreadCtx DBGI_ThreadCtx;
struct DBGI_ThreadCtx
{
Arena *arena;
DBGI_Scope *free_scope;
DBGI_TouchedBinary *free_tb;
DBGI_TouchedFuzzySearch *free_tfs;
};
////////////////////////////////
//~ rjf: Event Types
typedef enum DBGI_EventKind
{
DBGI_EventKind_Null,
DBGI_EventKind_ConversionStarted,
DBGI_EventKind_ConversionEnded,
DBGI_EventKind_ConversionFailureUnsupportedFormat,
DBGI_EventKind_COUNT
}
DBGI_EventKind;
typedef struct DBGI_Event DBGI_Event;
struct DBGI_Event
{
DBGI_EventKind kind;
String8 string;
};
typedef struct DBGI_EventNode DBGI_EventNode;
struct DBGI_EventNode
{
DBGI_EventNode *next;
DBGI_Event v;
};
typedef struct DBGI_EventList DBGI_EventList;
struct DBGI_EventList
{
DBGI_EventNode *first;
DBGI_EventNode *last;
U64 count;
};
////////////////////////////////
//~ rjf: Cross-Thread Shared State
@@ -288,7 +302,6 @@ struct DBGI_Shared
global DBGI_Shared *dbgi_shared = 0;
thread_static DBGI_ThreadCtx *dbgi_tctx = 0;
global DBGI_Parse dbgi_parse_nil = {0};
global DBGI_FuzzySearchResult dbgi_fuzzy_search_result_nil = {0};
////////////////////////////////
//~ rjf: Main Layer Initialization
@@ -317,6 +330,7 @@ internal String8 dbgi_forced_dbg_path_from_exe_path(Arena *arena, String8 exe_pa
internal DBGI_Scope *dbgi_scope_open(void);
internal void dbgi_scope_close(DBGI_Scope *scope);
internal void dbgi_scope_touch_binary__stripe_mutex_r_guarded(DBGI_Scope *scope, DBGI_Binary *binary);
internal void dbgi_scope_touch_fuzzy_search__stripe_mutex_r_guarded(DBGI_Scope *scope, DBGI_FuzzySearchNode *node);
////////////////////////////////
//~ rjf: Binary Cache Functions
@@ -328,7 +342,7 @@ internal DBGI_Parse *dbgi_parse_from_exe_path(DBGI_Scope *scope, String8 exe_pat
////////////////////////////////
//~ rjf: Fuzzy Search Cache Functions
internal DBGI_FuzzySearchResult *dbgi_fuzzy_search_result_from_key_exe_query(U128 key, String8 exe_path, String8 query, U64 endt_us);
internal DBGI_FuzzySearchItemArray dbgi_fuzzy_search_items_from_key_exe_query(DBGI_Scope *scope, U128 key, String8 exe_path, String8 query, U64 endt_us);
////////////////////////////////
//~ rjf: Parse Threads
@@ -344,7 +358,7 @@ internal void dbgi_parse_thread_entry_point(void *p);
////////////////////////////////
//~ rjf: Fuzzy Searching Threads
internal void dbgi_u2f_enqueue_req(U128 key, String8 exe_path, String8 query);
internal B32 dbgi_u2f_enqueue_req(U128 key, String8 exe_path, String8 query, U64 endt_us);
internal void dbgi_u2f_dequeue_req(Arena *arena, U128 *key_out, String8 *exe_path_out, String8 *query_out);
internal void dbgi_fuzzy_thread__entry_point(void *p);