mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-06-13 07:32:23 -07:00
bugfix evictions, correctly maintain downstream content hash counts
This commit is contained in:
@@ -437,7 +437,7 @@ ac_async_tick(void)
|
||||
for(;;)
|
||||
{
|
||||
// rjf: any new higher priority tasks? -> cancel
|
||||
if(task_idx == 1 && ins_atomic_u64_eval(req_take_counter_ptr) != 0) MutexScope(ac_shared->req_batches[0].mutex)
|
||||
if(task_idx == 1 && ins_atomic_u64_eval(req_take_counter_ptr) >= task->thin_count/2) MutexScope(ac_shared->req_batches[0].mutex)
|
||||
{
|
||||
if(ac_shared->req_batches[0].wide_count != 0 || ac_shared->req_batches[0].thin_count != 0)
|
||||
{
|
||||
|
||||
@@ -356,7 +356,7 @@ c_close_key(C_Key key)
|
||||
history_idx < C_KEY_HASH_HISTORY_STRONG_REF_COUNT && history_idx < n->hash_history_gen;
|
||||
history_idx += 1)
|
||||
{
|
||||
U128 hash = n->hash_history[(n->hash_history_gen+history_idx)%ArrayCount(n->hash_history)];
|
||||
U128 hash = n->hash_history[(n->hash_history_gen-1-history_idx) % ArrayCount(n->hash_history)];
|
||||
U64 hash_slot_idx = hash.u64[1]%c_shared->blob_slots_count;
|
||||
U64 hash_stripe_idx = hash_slot_idx%c_shared->blob_stripes_count;
|
||||
C_BlobSlot *hash_slot = &c_shared->blob_slots[hash_slot_idx];
|
||||
@@ -500,9 +500,8 @@ c_async_tick(void)
|
||||
{
|
||||
next = n->next;
|
||||
U64 key_ref_count = ins_atomic_u64_eval(&n->key_ref_count);
|
||||
U64 scope_ref_count = ins_atomic_u64_eval(&n->access_pt.access_refcount);
|
||||
U64 downstream_ref_count = ins_atomic_u64_eval(&n->downstream_ref_count);
|
||||
if(key_ref_count == 0 && scope_ref_count == 0 && downstream_ref_count == 0)
|
||||
if(access_pt_is_expired(&n->access_pt, .time = 5000000) && key_ref_count == 0 && downstream_ref_count == 0)
|
||||
{
|
||||
slot_has_work = 1;
|
||||
if(!write_mode)
|
||||
|
||||
@@ -6166,7 +6166,7 @@ ctrl_memory_artifact_create(String8 key, U64 gen, U64 *requested_gen, B32 *retry
|
||||
B32 pre_run_state = ins_atomic_u64_eval(&ctrl_state->ctrl_thread_run_state);
|
||||
{
|
||||
range_size = dim_1u64(vaddr_range_clamped);
|
||||
U64 page_size = os_get_system_info()->page_size;
|
||||
U64 page_size = os_get_system_info()->page_size; // TODO(rjf): @page_size_from_process
|
||||
U64 arena_size = AlignPow2(range_size + ARENA_HEADER_SIZE, page_size);
|
||||
range_arena = arena_alloc(.reserve_size = range_size+ARENA_HEADER_SIZE, .commit_size = range_size+ARENA_HEADER_SIZE);
|
||||
if(range_arena == 0)
|
||||
@@ -6289,7 +6289,7 @@ ctrl_key_from_process_vaddr_range(CTRL_Handle process, Rng1U64 vaddr_range, B32
|
||||
.gen = ctrl_mem_gen(),
|
||||
.slots_count = 2048,
|
||||
.stale_out = out_is_stale,
|
||||
.evict_threshold_us = 30000000);
|
||||
.evict_threshold_us = 10000000);
|
||||
C_Key content_key = {0};
|
||||
MemoryCopyStruct(&content_key, &artifact);
|
||||
access_close(access);
|
||||
@@ -6481,7 +6481,7 @@ ctrl_process_write(CTRL_Handle process, Rng1U64 range, void *src)
|
||||
if(result)
|
||||
{
|
||||
U64 endt_us = os_now_microseconds()+5000;
|
||||
U64 page_size = os_get_system_info()->page_size;
|
||||
U64 page_size = os_get_system_info()->page_size; // TODO(rjf): @page_size_from_process
|
||||
Rng1U64 page_range = r1u64(range.min/page_size, range.max/page_size);
|
||||
for EachInRange(page_idx, page_range)
|
||||
{
|
||||
|
||||
@@ -262,6 +262,7 @@ struct DASM_Artifact
|
||||
{
|
||||
Arena *arena;
|
||||
DASM_Info info;
|
||||
U128 data_hash;
|
||||
};
|
||||
|
||||
internal AC_Artifact
|
||||
@@ -470,12 +471,16 @@ dasm_artifact_create(String8 key, U64 gen, U64 *requested_gen, B32 *retry_out)
|
||||
retry_out[0] = 1;
|
||||
}
|
||||
|
||||
//- rjf: mark dependency on data hash
|
||||
c_hash_downstream_inc(hash);
|
||||
|
||||
//- rjf: fill result
|
||||
if(info_arena != 0)
|
||||
{
|
||||
artifact = push_array(info_arena, DASM_Artifact, 1);
|
||||
artifact->arena = info_arena;
|
||||
artifact->info = info;
|
||||
artifact->data_hash = hash;
|
||||
}
|
||||
|
||||
di_scope_close(di_scope);
|
||||
@@ -494,6 +499,7 @@ dasm_artifact_destroy(AC_Artifact artifact)
|
||||
DASM_Artifact *dasm_artifact = (DASM_Artifact *)artifact.u64[0];
|
||||
if(dasm_artifact == 0) { return; }
|
||||
c_close_key(dasm_artifact->info.text_key);
|
||||
c_hash_downstream_dec(dasm_artifact->data_hash);
|
||||
arena_release(dasm_artifact->arena);
|
||||
}
|
||||
|
||||
|
||||
@@ -1461,8 +1461,7 @@ rd_watch_row_info_from_row(Arena *arena, EV_Row *row)
|
||||
F32 next_pct = 0;
|
||||
#define take_pct() (next_pct = (F32)f64_from_str8(w_cfg->string), w_cfg = w_cfg->next, next_pct)
|
||||
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_CallStackFrame, row->eval, .default_pct = 0.05f, .pct = take_pct());
|
||||
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Eval, row->eval, .default_pct = 0.55f, .pct = take_pct());
|
||||
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Eval, e_eval_wrapf(row->eval, "hex((uint64)$)"), .default_pct = 0.20f, .pct = take_pct());
|
||||
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Eval, row->eval, .default_pct = 0.75f, .pct = take_pct());
|
||||
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Eval, (module == &ctrl_entity_nil ? (E_Eval)zero_struct : module_eval),
|
||||
.default_pct = 0.20f, .pct = take_pct());
|
||||
#undef take_pct
|
||||
|
||||
+8
-2
@@ -1957,6 +1957,7 @@ typedef struct TXT_Artifact TXT_Artifact;
|
||||
struct TXT_Artifact
|
||||
{
|
||||
Arena *arena;
|
||||
U128 data_hash;
|
||||
TXT_TextInfo info;
|
||||
};
|
||||
|
||||
@@ -2220,12 +2221,16 @@ txt_artifact_create(String8 key, U64 gen, U64 *requested_gen, B32 *retry_out)
|
||||
lane_sync();
|
||||
}
|
||||
|
||||
//- rjf: mark dependency on hash
|
||||
c_hash_downstream_inc(hash);
|
||||
|
||||
//- rjf: package as artifact
|
||||
if(lane_idx() == 0 && shared->arena != 0)
|
||||
{
|
||||
shared->artifact = push_array(shared->arena, TXT_Artifact, 1);
|
||||
shared->artifact->arena = shared->arena;
|
||||
shared->artifact->info = shared->info;
|
||||
shared->artifact->arena = shared->arena;
|
||||
shared->artifact->data_hash = hash;
|
||||
shared->artifact->info = shared->info;
|
||||
}
|
||||
lane_sync();
|
||||
|
||||
@@ -2242,6 +2247,7 @@ txt_artifact_destroy(AC_Artifact artifact)
|
||||
{
|
||||
TXT_Artifact *txt_artifact = (TXT_Artifact *)artifact.u64[0];
|
||||
if(txt_artifact == 0) { return; }
|
||||
c_hash_downstream_dec(txt_artifact->data_hash);
|
||||
arena_release(txt_artifact->arena);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user