perf: batch pending queue allocations in poll and retry

Replace per-module malloc calls in stk_pending_retry and stk_poll
with bulk allocations.

- stk_pending_retry: single realloc to module_count + stk_pending_count
  before the retry loop instead of realloc + 1 per module at attempt_load
- stk_poll unload loop: collect cascade deps into a batch array, call
  stk_pending_add_batch once after instead of stk_pending_add per module
- stk_poll cascade loop: same pattern, batch collect and add once per
  cascade iteration
This commit is contained in:
anth64 committed 2026-03-07 14:21:15 +01:00
1 parent 06d04cf92b
commit 49ecd8fde5
2 files changed
+51 -17

No files matched your search

+3 -3
View File
@@ -1026,6 +1026,9 @@ size_t stk_pending_retry(void)
return 0;
}
if (stk_module_realloc_memory(module_count + stk_pending_count) != 0)
return 0;
for (i = 0; i < stk_pending_count; i++) {
extract_module_id(stk_pending[i], pending_id);
if (is_mod_loaded(pending_id) >= 0) {
@@ -1073,9 +1076,6 @@ size_t stk_pending_retry(void)
continue;
attempt_load:
if (stk_module_realloc_memory(module_count + 1) != 0)
continue;
result = stk_module_load(stk_pending[i], module_count);
if (result != STK_MOD_INIT_SUCCESS)
continue;