Skip to content

Commit

Permalink
portindex: start threads on demand
Browse files Browse the repository at this point in the history
Start with 1 thread and allow tpool::post to start new ones (up to the
maximum) if there are none idle. This should improve startup time when
indexing a repo with less than $buildmakejobs ports in it.
  • Loading branch information
jmroot committed Jan 20, 2025
1 parent 914c648 commit bdeaa81
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/port/portindex.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ proc init_threads {} {
[list set oldmtime $oldmtime] \n
}
set maxjobs [macports::get_parallel_jobs no]
set poolid [tpool::create -minworkers $maxjobs -maxworkers $maxjobs -initcmd $worker_init_script]
set poolid [tpool::create -minworkers 1 -maxworkers $maxjobs -initcmd $worker_init_script]
set pending_jobs [dict create]
set nextjobnum 0
tsv::set mutexes PortIndex [thread::mutex create]
Expand Down Expand Up @@ -243,7 +243,7 @@ proc handle_completed_jobs {} {
if {$subport eq "" && [tsv::exists subports $jobnum]} {
foreach nextsubport [tsv::get subports $jobnum] {
tsv::set status $nextjobnum 99
set jobid [tpool::post -nowait $poolid [list pindex $portdir $nextjobnum $nextsubport]]
set jobid [tpool::post $poolid [list pindex $portdir $nextjobnum $nextsubport]]
dict set pending_jobs $jobid [list $nextjobnum $portdir $nextsubport]
incr nextjobnum
}
Expand Down Expand Up @@ -284,7 +284,7 @@ proc pindex_queue {portdir} {
# Start with worst status so we get it when the thread
# returns due to ctrl-c etc.
tsv::set status $nextjobnum 99
set jobid [tpool::post -nowait $poolid [list pindex $portdir $nextjobnum {}]]
set jobid [tpool::post $poolid [list pindex $portdir $nextjobnum {}]]
dict set pending_jobs $jobid [list $nextjobnum $portdir {}]
incr nextjobnum
}
Expand Down

0 comments on commit bdeaa81

Please sign in to comment.