diff --git a/src/ctrl/ctrl_core.c b/src/ctrl/ctrl_core.c index 0a8938b3..d056f410 100644 --- a/src/ctrl/ctrl_core.c +++ b/src/ctrl/ctrl_core.c @@ -4125,7 +4125,13 @@ ctrl_thread__next_dmn_event(Arena *arena, DMN_CtrlCtx *ctrl_ctx, CTRL_Msg *msg, // loaded, and pre-emptively convert all of them (which for us is the // heaviest part of debug info loading, if native RDI is not used). // - if(event->kind == DMN_EventKind_LoadModule) + // only do this on the first ever loaded module, *or* once we get beyond 256 + // modules (a very bad heuristic that may or may not inform us that we are + // dealing with insane-town projects) + // + if(event->kind == DMN_EventKind_LoadModule && + (ctrl_state->ctrl_thread_entity_store->entity_kind_counts[CTRL_EntityKind_Module] > 256 || + ctrl_state->ctrl_thread_entity_store->entity_kind_counts[CTRL_EntityKind_Module] == 1)) { //- rjf: unpack event CTRL_Handle process_handle = ctrl_handle_make(CTRL_MachineID_Local, event->process); @@ -4177,6 +4183,11 @@ ctrl_thread__next_dmn_event(Arena *arena, DMN_CtrlCtx *ctrl_ctx, CTRL_Msg *msg, parent_dir_node = next_child; } + //- rjf: count modules + { + parent_dir_node->module_direct_count += 1; + } + //- rjf: iterate from dir node up its ancestor chain - do recursive // searches if this is an ancestor of loaded modules, it has not been // searched yet, but it has >4 child branches, meaning it looks like @@ -4185,7 +4196,7 @@ ctrl_thread__next_dmn_event(Arena *arena, DMN_CtrlCtx *ctrl_ctx, CTRL_Msg *msg, DI_KeyList preemptively_loaded_keys = {0}; for(CTRL_DbgDirNode *dir_node = parent_dir_node; dir_node != 0; dir_node = dir_node->parent) { - if(dir_node->search_count == 0 && dir_node->child_count >= 4) + if(dir_node->search_count == 0 && dir_node->module_direct_count >= 1) { //- rjf: form full path of this directory node String8List dir_node_path_parts = {0}; diff --git a/src/ctrl/ctrl_core.h b/src/ctrl/ctrl_core.h index da4a4501..c7b0733b 100644 --- a/src/ctrl/ctrl_core.h +++ b/src/ctrl/ctrl_core.h @@ -838,6 +838,7 @@ struct CTRL_DbgDirNode String8 name; U64 search_count; U64 child_count; + U64 module_direct_count; }; //////////////////////////////// diff --git a/src/dbgi/dbgi.c b/src/dbgi/dbgi.c index 0013199c..143eb88c 100644 --- a/src/dbgi/dbgi.c +++ b/src/dbgi/dbgi.c @@ -491,6 +491,7 @@ di_open(DI_Key *key) if(node->ref_count == 1) { di_u2p_enqueue_key(&key_normalized, max_U64); + ins_atomic_u64_eval_assign(&node->last_time_requested_us, os_now_microseconds()); ins_atomic_u64_inc_eval(&node->request_count); async_push_work(di_parse_work, .completion_counter = &node->completion_count); } @@ -609,9 +610,11 @@ di_rdi_from_key(DI_Scope *scope, DI_Key *key, U64 endt_us) //- rjf: parse not done, not working -> ask for parse if(node != 0 && !node->parse_done && - ins_atomic_u64_eval(&node->request_count) == ins_atomic_u64_eval(&node->completion_count) && + (ins_atomic_u64_eval(&node->request_count) == ins_atomic_u64_eval(&node->completion_count) || + ins_atomic_u64_eval(&node->last_time_requested_us)+100000 < os_now_microseconds()) && di_u2p_enqueue_key(&key_normalized, endt_us)) { + ins_atomic_u64_eval_assign(&node->last_time_requested_us, os_now_microseconds()); ins_atomic_u64_inc_eval(&node->request_count); async_push_work(di_parse_work, .completion_counter = &node->completion_count); } diff --git a/src/dbgi/dbgi.h b/src/dbgi/dbgi.h index bb567f00..69ab10be 100644 --- a/src/dbgi/dbgi.h +++ b/src/dbgi/dbgi.h @@ -94,6 +94,7 @@ struct DI_Node U64 request_count; U64 completion_count; U64 is_working; + U64 last_time_requested_us; // rjf: key DI_Key key; diff --git a/src/file_stream/file_stream.c b/src/file_stream/file_stream.c index 959e6d61..3bb3a86f 100644 --- a/src/file_stream/file_stream.c +++ b/src/file_stream/file_stream.c @@ -146,11 +146,13 @@ fs_hash_from_path_range(String8 path, Rng1U64 range, U64 endt_us) } // rjf: try to send stream request - if(ins_atomic_u64_eval(&range_node->request_count) == ins_atomic_u64_eval(&range_node->completion_count) && + if((ins_atomic_u64_eval(&range_node->request_count) == ins_atomic_u64_eval(&range_node->completion_count) || + ins_atomic_u64_eval(&range_node->last_time_requested_us)+100000 < os_now_microseconds()) && fs_u2s_enqueue_req(range, path, endt_us)) { - async_push_work(fs_stream_work, .completion_counter = &range_node->completion_count); + ins_atomic_u64_eval_assign(&range_node->last_time_requested_us, os_now_microseconds()); ins_atomic_u64_inc_eval(&range_node->request_count); + async_push_work(fs_stream_work, .completion_counter = &range_node->completion_count); } // rjf: try to reobtain results @@ -419,8 +421,9 @@ fs_detector_thread__entry_point(void *p) if(ins_atomic_u64_eval(&range_n->request_count) == ins_atomic_u64_eval(&range_n->completion_count) && fs_u2s_enqueue_req(range_n->range, n->path, os_now_microseconds()+100000)) { - async_push_work(fs_stream_work, .completion_counter = &range_n->completion_count); + ins_atomic_u64_eval_assign(&range_n->last_time_requested_us, os_now_microseconds()); ins_atomic_u64_inc_eval(&range_n->request_count); + async_push_work(fs_stream_work, .completion_counter = &range_n->completion_count); } } } diff --git a/src/file_stream/file_stream.h b/src/file_stream/file_stream.h index 54098da0..80b1e34a 100644 --- a/src/file_stream/file_stream.h +++ b/src/file_stream/file_stream.h @@ -14,6 +14,7 @@ struct FS_RangeNode Rng1U64 range; U64 request_count; U64 completion_count; + U64 last_time_requested_us; }; typedef struct FS_RangeSlot FS_RangeSlot;