From e5eac930715dda164eccbaaefa9cfca605491185 Mon Sep 17 00:00:00 2001 From: Spencer Brower Date: Wed, 17 Jun 2026 14:42:33 -0400 Subject: [PATCH] perf(findr): Pre-allocate thread-pool. --- walker.odin | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/walker.odin b/walker.odin index ea20bfa..10f1d0c 100644 --- a/walker.odin +++ b/walker.odin @@ -47,7 +47,7 @@ WalkerPool :: struct { results_mutex: sync.Mutex, active: i64, done: sync.One_Shot_Event, - threads: [dynamic]^thread.Thread, + threads: []^thread.Thread, opts: WalkOptions, pattern_re: regex.Regular_Expression, has_pattern: bool, @@ -63,7 +63,7 @@ walk :: proc(roots: []string, results: ^[dynamic]string, opts: WalkOptions, thre pool.queue = make([dynamic]WorkItem) pool.results = results pool.active = i64(len(roots)) - pool.threads = make([dynamic]^thread.Thread) + pool.threads = make([]^thread.Thread, thread_count) pool.all_contexts = make([dynamic]^GIContext) pool.opts = opts pool.exclude_gi = nil @@ -100,7 +100,7 @@ walk :: proc(roots: []string, results: ^[dynamic]string, opts: WalkOptions, thre t.data = rawptr(pool) t.init_context = context thread.start(t) - append(&pool.threads, t) + pool.threads[i] = t } sync.one_shot_event_wait(&pool.done)