mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2024-12-12 03:34:34 +08:00
util/u_queue: always enable UTIL_QUEUE_INIT_SCALE_THREADS, remove the flag
It means that threads are created on demand except for the first one. It reduces process startup time. Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24173>
This commit is contained in:
parent
bfdfe5aa82
commit
4b93ae7e7a
@ -1290,7 +1290,6 @@ static struct pipe_screen *radeonsi_screen_create_impl(struct radeon_winsys *ws,
|
||||
if (!util_queue_init(&sscreen->shader_compiler_queue, "sh", num_slots,
|
||||
num_comp_hi_threads,
|
||||
UTIL_QUEUE_INIT_RESIZE_IF_FULL |
|
||||
UTIL_QUEUE_INIT_SCALE_THREADS |
|
||||
UTIL_QUEUE_INIT_SET_FULL_THREAD_AFFINITY, NULL)) {
|
||||
si_destroy_shader_cache(sscreen);
|
||||
FREE(sscreen->nir_options);
|
||||
@ -1302,7 +1301,6 @@ static struct pipe_screen *radeonsi_screen_create_impl(struct radeon_winsys *ws,
|
||||
if (!util_queue_init(&sscreen->shader_compiler_queue_low_priority, "shlo", num_slots,
|
||||
num_comp_lo_threads,
|
||||
UTIL_QUEUE_INIT_RESIZE_IF_FULL |
|
||||
UTIL_QUEUE_INIT_SCALE_THREADS |
|
||||
UTIL_QUEUE_INIT_SET_FULL_THREAD_AFFINITY |
|
||||
UTIL_QUEUE_INIT_USE_MINIMUM_PRIORITY, NULL)) {
|
||||
si_destroy_shader_cache(sscreen);
|
||||
|
@ -3025,7 +3025,7 @@ zink_internal_create_screen(const struct pipe_screen_config *config)
|
||||
goto fail;
|
||||
}
|
||||
if (!util_queue_init(&screen->cache_get_thread, "zcfq", 8, 4,
|
||||
UTIL_QUEUE_INIT_RESIZE_IF_FULL | UTIL_QUEUE_INIT_SCALE_THREADS, screen))
|
||||
UTIL_QUEUE_INIT_RESIZE_IF_FULL, screen))
|
||||
goto fail;
|
||||
populate_format_props(screen);
|
||||
|
||||
|
@ -87,7 +87,6 @@ disk_cache_init_queue(struct disk_cache *cache)
|
||||
* doesn't stall.
|
||||
*/
|
||||
return util_queue_init(&cache->cache_queue, "disk$", 32, 4,
|
||||
UTIL_QUEUE_INIT_SCALE_THREADS |
|
||||
UTIL_QUEUE_INIT_RESIZE_IF_FULL |
|
||||
UTIL_QUEUE_INIT_USE_MINIMUM_PRIORITY |
|
||||
UTIL_QUEUE_INIT_SET_FULL_THREAD_AFFINITY, NULL);
|
||||
|
@ -442,9 +442,10 @@ util_queue_init(struct util_queue *queue,
|
||||
snprintf(queue->name, sizeof(queue->name), "%s", name);
|
||||
}
|
||||
|
||||
queue->create_threads_on_demand = true;
|
||||
queue->flags = flags;
|
||||
queue->max_threads = num_threads;
|
||||
queue->num_threads = (flags & UTIL_QUEUE_INIT_SCALE_THREADS) ? 1 : num_threads;
|
||||
queue->num_threads = 1;
|
||||
queue->max_jobs = max_jobs;
|
||||
queue->global_data = global_data;
|
||||
|
||||
@ -582,7 +583,7 @@ util_queue_add_job_locked(struct util_queue *queue,
|
||||
|
||||
/* Scale the number of threads up if there's already one job waiting. */
|
||||
if (queue->num_queued > 0 &&
|
||||
queue->flags & UTIL_QUEUE_INIT_SCALE_THREADS &&
|
||||
queue->create_threads_on_demand &&
|
||||
execute != util_queue_finish_execute &&
|
||||
queue->num_threads < queue->max_threads) {
|
||||
util_queue_adjust_num_threads(queue, queue->num_threads + 1, true);
|
||||
@ -719,8 +720,7 @@ util_queue_finish(struct util_queue *queue)
|
||||
* Also note that util_queue_add_job can unlock the mutex if there is not
|
||||
* enough space in the queue and wait for space.
|
||||
*/
|
||||
unsigned saved_flags = queue->flags;
|
||||
queue->flags &= ~UTIL_QUEUE_INIT_SCALE_THREADS;
|
||||
queue->create_threads_on_demand = false;
|
||||
|
||||
fences = malloc(queue->num_threads * sizeof(*fences));
|
||||
util_barrier_init(&barrier, queue->num_threads);
|
||||
@ -730,7 +730,7 @@ util_queue_finish(struct util_queue *queue)
|
||||
util_queue_add_job_locked(queue, &barrier, &fences[i],
|
||||
util_queue_finish_execute, NULL, 0, true);
|
||||
}
|
||||
queue->flags = saved_flags;
|
||||
queue->create_threads_on_demand = true;
|
||||
mtx_unlock(&queue->lock);
|
||||
|
||||
for (unsigned i = 0; i < queue->num_threads; ++i) {
|
||||
|
@ -50,7 +50,6 @@ extern "C" {
|
||||
#define UTIL_QUEUE_INIT_USE_MINIMUM_PRIORITY (1 << 0)
|
||||
#define UTIL_QUEUE_INIT_RESIZE_IF_FULL (1 << 1)
|
||||
#define UTIL_QUEUE_INIT_SET_FULL_THREAD_AFFINITY (1 << 2)
|
||||
#define UTIL_QUEUE_INIT_SCALE_THREADS (1 << 3)
|
||||
|
||||
#if UTIL_FUTEX_SUPPORTED
|
||||
#define UTIL_QUEUE_FENCE_FUTEX
|
||||
@ -206,6 +205,7 @@ struct util_queue_job {
|
||||
struct util_queue {
|
||||
char name[14]; /* 13 characters = the thread name without the index */
|
||||
mtx_t lock;
|
||||
bool create_threads_on_demand;
|
||||
cnd_t has_queued_cond;
|
||||
cnd_t has_space_cond;
|
||||
thrd_t *threads;
|
||||
|
Loading…
Reference in New Issue
Block a user