mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-08-06 13:58:40 +00:00
extend artifact cache nodes with last requested vs. last completed gen; pass last requested gen to artifact creation to support cancellation
This commit is contained in:
@@ -81,7 +81,8 @@ ac_artifact_from_key_(Access *access, String8 key, AC_ArtifactParams *params, U6
|
|||||||
{
|
{
|
||||||
if(str8_match(n->key, key, 0))
|
if(str8_match(n->key, key, 0))
|
||||||
{
|
{
|
||||||
B32 is_stale = (n->gen != params->gen);
|
ins_atomic_u64_eval_assign(&n->last_requested_gen, params->gen);
|
||||||
|
B32 is_stale = (n->last_completed_gen != params->gen);
|
||||||
if(ins_atomic_u64_eval(&n->completion_count) != 0 && (!is_stale || !(params->flags & AC_Flag_WaitForFresh)))
|
if(ins_atomic_u64_eval(&n->completion_count) != 0 && (!is_stale || !(params->flags & AC_Flag_WaitForFresh)))
|
||||||
{
|
{
|
||||||
got_artifact = 1;
|
got_artifact = 1;
|
||||||
@@ -159,6 +160,7 @@ ac_artifact_from_key_(Access *access, String8 key, AC_ArtifactParams *params, U6
|
|||||||
}
|
}
|
||||||
n->v.key = str8_copy(req_batch->arena, key);
|
n->v.key = str8_copy(req_batch->arena, key);
|
||||||
n->v.gen = params->gen;
|
n->v.gen = params->gen;
|
||||||
|
n->v.last_requested_gen = &node->last_requested_gen;
|
||||||
n->v.create = params->create;
|
n->v.create = params->create;
|
||||||
}
|
}
|
||||||
cond_var_broadcast(async_tick_start_cond_var);
|
cond_var_broadcast(async_tick_start_cond_var);
|
||||||
@@ -166,10 +168,10 @@ ac_artifact_from_key_(Access *access, String8 key, AC_ArtifactParams *params, U6
|
|||||||
}
|
}
|
||||||
|
|
||||||
// rjf: get value from node, if possible
|
// rjf: get value from node, if possible
|
||||||
if(!got_artifact && ins_atomic_u64_eval(&node->completion_count) != 0 && ((node->gen == params->gen) || !(params->flags & AC_Flag_WaitForFresh) || out_of_time))
|
if(!got_artifact && ins_atomic_u64_eval(&node->completion_count) != 0 && ((node->last_completed_gen == params->gen) || !(params->flags & AC_Flag_WaitForFresh) || out_of_time))
|
||||||
{
|
{
|
||||||
got_artifact = 1;
|
got_artifact = 1;
|
||||||
artifact_is_stale = (node->gen == params->gen);
|
artifact_is_stale = (node->last_completed_gen == params->gen);
|
||||||
artifact = node->val;
|
artifact = node->val;
|
||||||
access_touch(access, &node->access_pt, stripe->cv);
|
access_touch(access, &node->access_pt, stripe->cv);
|
||||||
}
|
}
|
||||||
@@ -327,7 +329,7 @@ ac_async_tick(void)
|
|||||||
|
|
||||||
// rjf: compute val
|
// rjf: compute val
|
||||||
B32 retry = 0;
|
B32 retry = 0;
|
||||||
AC_Artifact val = r->create(r->key, &retry);
|
AC_Artifact val = r->create(r->key, r->gen, r->last_requested_gen, &retry);
|
||||||
|
|
||||||
// rjf: retry? -> resubmit request
|
// rjf: retry? -> resubmit request
|
||||||
if(retry && lane_idx() == 0)
|
if(retry && lane_idx() == 0)
|
||||||
@@ -377,7 +379,7 @@ ac_async_tick(void)
|
|||||||
{
|
{
|
||||||
if(str8_match(n->key, r->key, 0))
|
if(str8_match(n->key, r->key, 0))
|
||||||
{
|
{
|
||||||
n->gen = r->gen;
|
n->last_completed_gen = r->gen;
|
||||||
n->val = val;
|
n->val = val;
|
||||||
ins_atomic_u64_dec_eval(&n->working_count);
|
ins_atomic_u64_dec_eval(&n->working_count);
|
||||||
ins_atomic_u64_inc_eval(&n->completion_count);
|
ins_atomic_u64_inc_eval(&n->completion_count);
|
||||||
@@ -408,7 +410,7 @@ ac_async_tick(void)
|
|||||||
|
|
||||||
// rjf: compute val
|
// rjf: compute val
|
||||||
B32 retry = 0;
|
B32 retry = 0;
|
||||||
AC_Artifact val = r->create(r->key, &retry);
|
AC_Artifact val = r->create(r->key, r->gen, r->last_requested_gen, &retry);
|
||||||
|
|
||||||
// rjf: retry? -> resubmit request
|
// rjf: retry? -> resubmit request
|
||||||
if(retry)
|
if(retry)
|
||||||
@@ -458,7 +460,7 @@ ac_async_tick(void)
|
|||||||
{
|
{
|
||||||
if(str8_match(n->key, r->key, 0))
|
if(str8_match(n->key, r->key, 0))
|
||||||
{
|
{
|
||||||
n->gen = r->gen;
|
n->last_completed_gen = r->gen;
|
||||||
n->val = val;
|
n->val = val;
|
||||||
ins_atomic_u64_dec_eval(&n->working_count);
|
ins_atomic_u64_dec_eval(&n->working_count);
|
||||||
ins_atomic_u64_inc_eval(&n->completion_count);
|
ins_atomic_u64_inc_eval(&n->completion_count);
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ struct AC_Artifact
|
|||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ rjf: Artifact Computation Function Types
|
//~ rjf: Artifact Computation Function Types
|
||||||
|
|
||||||
typedef AC_Artifact AC_CreateFunctionType(String8 key, B32 *retry_out);
|
typedef AC_Artifact AC_CreateFunctionType(String8 key, U64 gen, U64 *requested_gen, B32 *retry_out);
|
||||||
typedef void AC_DestroyFunctionType(AC_Artifact artifact);
|
typedef void AC_DestroyFunctionType(AC_Artifact artifact);
|
||||||
|
|
||||||
typedef U32 AC_Flags;
|
typedef U32 AC_Flags;
|
||||||
@@ -48,6 +48,7 @@ struct AC_Request
|
|||||||
{
|
{
|
||||||
String8 key;
|
String8 key;
|
||||||
U64 gen;
|
U64 gen;
|
||||||
|
U64 *last_requested_gen;
|
||||||
AC_CreateFunctionType *create;
|
AC_CreateFunctionType *create;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -66,7 +67,8 @@ struct AC_Node
|
|||||||
|
|
||||||
// rjf: key/gen/value
|
// rjf: key/gen/value
|
||||||
String8 key;
|
String8 key;
|
||||||
U64 gen;
|
U64 last_requested_gen;
|
||||||
|
U64 last_completed_gen;
|
||||||
AC_Artifact val;
|
AC_Artifact val;
|
||||||
|
|
||||||
// rjf: metadata
|
// rjf: metadata
|
||||||
@@ -74,6 +76,8 @@ struct AC_Node
|
|||||||
U64 working_count;
|
U64 working_count;
|
||||||
U64 completion_count;
|
U64 completion_count;
|
||||||
U64 evict_threshold_us;
|
U64 evict_threshold_us;
|
||||||
|
B32 cancelled;
|
||||||
|
U64 _unused_;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct AC_Slot AC_Slot;
|
typedef struct AC_Slot AC_Slot;
|
||||||
|
|||||||
@@ -7464,7 +7464,7 @@ ASYNC_WORK_DEF(ctrl_call_stack_tree_build_work)
|
|||||||
//~ rjf: Process Memory Artifact Cache Hooks / Lookups
|
//~ rjf: Process Memory Artifact Cache Hooks / Lookups
|
||||||
|
|
||||||
internal AC_Artifact
|
internal AC_Artifact
|
||||||
ctrl_memory_artifact_create(String8 key, B32 *retry_out)
|
ctrl_memory_artifact_create(String8 key, U64 gen, U64 *requested_gen, B32 *retry_out)
|
||||||
{
|
{
|
||||||
AC_Artifact artifact = {0};
|
AC_Artifact artifact = {0};
|
||||||
{
|
{
|
||||||
@@ -7631,7 +7631,7 @@ ctrl_key_from_process_vaddr_range_new(CTRL_Handle process, Rng1U64 vaddr_range,
|
|||||||
//~ rjf: Call Stack Artifact Cache Hooks / Lookups
|
//~ rjf: Call Stack Artifact Cache Hooks / Lookups
|
||||||
|
|
||||||
internal AC_Artifact
|
internal AC_Artifact
|
||||||
ctrl_call_stack_artifact_create(String8 key, B32 *retry_out)
|
ctrl_call_stack_artifact_create(String8 key, U64 gen, U64 *requested_gen, B32 *retry_out)
|
||||||
{
|
{
|
||||||
AC_Artifact artifact = {0};
|
AC_Artifact artifact = {0};
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1253,14 +1253,14 @@ ASYNC_WORK_DEF(ctrl_call_stack_tree_build_work);
|
|||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ rjf: Process Memory Artifact Cache Hooks / Lookups
|
//~ rjf: Process Memory Artifact Cache Hooks / Lookups
|
||||||
|
|
||||||
internal AC_Artifact ctrl_memory_artifact_create(String8 key, B32 *retry_out);
|
internal AC_Artifact ctrl_memory_artifact_create(String8 key, U64 gen, U64 *requested_gen, B32 *retry_out);
|
||||||
internal void ctrl_memory_artifact_destroy(AC_Artifact artifact);
|
internal void ctrl_memory_artifact_destroy(AC_Artifact artifact);
|
||||||
internal C_Key ctrl_key_from_process_vaddr_range_new(CTRL_Handle process, Rng1U64 vaddr_range, B32 zero_terminated, U64 endt_us, B32 *out_is_stale);
|
internal C_Key ctrl_key_from_process_vaddr_range_new(CTRL_Handle process, Rng1U64 vaddr_range, B32 zero_terminated, U64 endt_us, B32 *out_is_stale);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ rjf: Call Stack Artifact Cache Hooks / Lookups
|
//~ rjf: Call Stack Artifact Cache Hooks / Lookups
|
||||||
|
|
||||||
internal AC_Artifact ctrl_call_stack_artifact_create(String8 key, B32 *retry_out);
|
internal AC_Artifact ctrl_call_stack_artifact_create(String8 key, U64 gen, U64 *requested_gen, B32 *retry_out);
|
||||||
internal void ctrl_call_stack_artifact_destroy(AC_Artifact artifact);
|
internal void ctrl_call_stack_artifact_destroy(AC_Artifact artifact);
|
||||||
internal CTRL_CallStack ctrl_call_stack_from_thread_new(Access *access, CTRL_Handle thread_handle, B32 high_priority, U64 endt_us);
|
internal CTRL_CallStack ctrl_call_stack_from_thread_new(Access *access, CTRL_Handle thread_handle, B32 high_priority, U64 endt_us);
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -265,7 +265,7 @@ struct DASM_Artifact
|
|||||||
};
|
};
|
||||||
|
|
||||||
internal AC_Artifact
|
internal AC_Artifact
|
||||||
dasm_artifact_create(String8 key, B32 *retry_out)
|
dasm_artifact_create(String8 key, U64 gen, U64 *requested_gen, B32 *retry_out)
|
||||||
{
|
{
|
||||||
DASM_Artifact *artifact = 0;
|
DASM_Artifact *artifact = 0;
|
||||||
if(lane_idx() == 0)
|
if(lane_idx() == 0)
|
||||||
|
|||||||
+1
-1
@@ -197,7 +197,7 @@ internal U64 dasm_line_array_code_off_from_idx(DASM_LineArray *array, U64 idx);
|
|||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ rjf: Artifact Cache Hooks / Lookups
|
//~ rjf: Artifact Cache Hooks / Lookups
|
||||||
|
|
||||||
internal AC_Artifact dasm_artifact_create(String8 key, B32 *retry_out);
|
internal AC_Artifact dasm_artifact_create(String8 key, U64 gen, U64 *requested_gen, B32 *retry_out);
|
||||||
internal void dasm_artifact_destroy(AC_Artifact artifact);
|
internal void dasm_artifact_destroy(AC_Artifact artifact);
|
||||||
internal DASM_Info dasm_info_from_hash_params(Access *access, U128 hash, DASM_Params *params);
|
internal DASM_Info dasm_info_from_hash_params(Access *access, U128 hash, DASM_Params *params);
|
||||||
internal DASM_Info dasm_info_from_key_params(Access *access, C_Key key, DASM_Params *params, U128 *hash_out);
|
internal DASM_Info dasm_info_from_key_params(Access *access, C_Key key, DASM_Params *params, U128 *hash_out);
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ fs_change_gen(void)
|
|||||||
//~ rjf: Cache Interaction
|
//~ rjf: Cache Interaction
|
||||||
|
|
||||||
internal AC_Artifact
|
internal AC_Artifact
|
||||||
fs_artifact_create(String8 key, B32 *retry_out)
|
fs_artifact_create(String8 key, U64 gen, U64 *requested_gen, B32 *retry_out)
|
||||||
{
|
{
|
||||||
ProfBeginFunction();
|
ProfBeginFunction();
|
||||||
Temp scratch = scratch_begin(0, 0);
|
Temp scratch = scratch_begin(0, 0);
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ internal U64 fs_change_gen(void);
|
|||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ rjf: Artifact Cache Hooks / Accessing API
|
//~ rjf: Artifact Cache Hooks / Accessing API
|
||||||
|
|
||||||
internal AC_Artifact fs_artifact_create(String8 key, B32 *retry_out);
|
internal AC_Artifact fs_artifact_create(String8 key, U64 gen, U64 *requested_gen, B32 *retry_out);
|
||||||
internal void fs_artifact_destroy(AC_Artifact artifact);
|
internal void fs_artifact_destroy(AC_Artifact artifact);
|
||||||
|
|
||||||
internal C_Key fs_key_from_path_range(String8 path, Rng1U64 range, U64 endt_us);
|
internal C_Key fs_key_from_path_range(String8 path, Rng1U64 range, U64 endt_us);
|
||||||
|
|||||||
@@ -3750,7 +3750,7 @@ struct RD_BitmapCanvasBoxDrawData
|
|||||||
};
|
};
|
||||||
|
|
||||||
internal AC_Artifact
|
internal AC_Artifact
|
||||||
rd_bitmap_artifact_create(String8 key, B32 *retry_out)
|
rd_bitmap_artifact_create(String8 key, U64 gen, U64 *requested_gen, B32 *retry_out)
|
||||||
{
|
{
|
||||||
Access *access = access_open();
|
Access *access = access_open();
|
||||||
|
|
||||||
@@ -4364,7 +4364,7 @@ struct RD_Geo3DBoxDrawData
|
|||||||
};
|
};
|
||||||
|
|
||||||
internal AC_Artifact
|
internal AC_Artifact
|
||||||
rd_geo3d_artifact_create(String8 key, B32 *retry_out)
|
rd_geo3d_artifact_create(String8 key, U64 gen, U64 *requested_gen, B32 *retry_out)
|
||||||
{
|
{
|
||||||
Access *access = access_open();
|
Access *access = access_open();
|
||||||
U128 hash = {0};
|
U128 hash = {0};
|
||||||
|
|||||||
+1
-1
@@ -1969,7 +1969,7 @@ struct TXT_ArtifactCreateShared
|
|||||||
};
|
};
|
||||||
|
|
||||||
internal AC_Artifact
|
internal AC_Artifact
|
||||||
txt_artifact_create(String8 key, B32 *retry_out)
|
txt_artifact_create(String8 key, U64 gen, U64 *requested_gen, B32 *retry_out)
|
||||||
{
|
{
|
||||||
ProfBeginFunction();
|
ProfBeginFunction();
|
||||||
Temp scratch = scratch_begin(0, 0);
|
Temp scratch = scratch_begin(0, 0);
|
||||||
|
|||||||
+1
-1
@@ -203,7 +203,7 @@ internal TXT_ScopeNode *txt_scope_node_from_info_pt(TXT_TextInfo *info, TxtPt pt
|
|||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ rjf: Artifact Cache Hooks / Lookups
|
//~ rjf: Artifact Cache Hooks / Lookups
|
||||||
|
|
||||||
internal AC_Artifact txt_artifact_create(String8 key, B32 *retry_out);
|
internal AC_Artifact txt_artifact_create(String8 key, U64 gen, U64 *requested_gen, B32 *retry_out);
|
||||||
internal void txt_artifact_destroy(AC_Artifact artifact);
|
internal void txt_artifact_destroy(AC_Artifact artifact);
|
||||||
internal TXT_TextInfo txt_text_info_from_hash_lang(Access *access, U128 hash, TXT_LangKind lang);
|
internal TXT_TextInfo txt_text_info_from_hash_lang(Access *access, U128 hash, TXT_LangKind lang);
|
||||||
internal TXT_TextInfo txt_text_info_from_key_lang(Access *access, C_Key key, TXT_LangKind lang, U128 *hash_out);
|
internal TXT_TextInfo txt_text_info_from_key_lang(Access *access, C_Key key, TXT_LangKind lang, U128 *hash_out);
|
||||||
|
|||||||
Reference in New Issue
Block a user