[Bf-blender-cvs] [fe226dc5b3] unlock_task_scheduler: Do less nanosleep loops.
Bastien Montagne
noreply at git.blender.org
Fri Mar 3 17:49:13 CET 2017
Commit: fe226dc5b3a934d684528b67a3befb3630da4c0b
Author: Bastien Montagne
Date: Fri Dec 23 12:40:47 2016 +0100
Branches: unlock_task_scheduler
https://developer.blender.org/rBfe226dc5b3a934d684528b67a3befb3630da4c0b
Do less nanosleep loops.
tested that already without much change yesterday, but for some reasons
today it gives me another 2-3% speedup in both test files.
And it should also mitigate the (supposed) almost-starving situation,
hopefully.
===================================================================
M source/blender/blenlib/BLI_task.h
M source/blender/blenlib/intern/task.c
===================================================================
diff --git a/source/blender/blenlib/BLI_task.h b/source/blender/blenlib/BLI_task.h
index d27bf4dad2..a551124375 100644
--- a/source/blender/blenlib/BLI_task.h
+++ b/source/blender/blenlib/BLI_task.h
@@ -97,7 +97,7 @@ void BLI_task_pool_work_and_wait(TaskPool *pool);
void BLI_task_pool_cancel(TaskPool *pool);
/* set number of threads allowed to be used by this pool */
-void BLI_pool_set_num_threads(TaskPool *pool, int num_threads);
+void BLI_pool_set_num_threads(TaskPool *pool, size_t num_threads);
/* for worker threads, test if canceled */
bool BLI_task_pool_canceled(TaskPool *pool);
diff --git a/source/blender/blenlib/intern/task.c b/source/blender/blenlib/intern/task.c
index e53327640f..f3ad071b88 100644
--- a/source/blender/blenlib/intern/task.c
+++ b/source/blender/blenlib/intern/task.c
@@ -49,7 +49,7 @@
#define MEMPOOL_SIZE 256
/* Parameters controlling how much we spin in nanosleeps before switching to real condition-controlled sleeping. */
-#define NANOSLEEP_MAX_SPINNING 1000 /* Number of failed attempt to get a task before going to condition waiting. */
+#define NANOSLEEP_MAX_SPINNING 200 /* Number of failed attempt to get a task before going to condition waiting. */
#define NANOSLEEP_DURATION (const struct timespec[]){{0, 200L}} /* Nanosleep duration (in nano-seconds). */
typedef struct Task {
@@ -743,7 +743,7 @@ void BLI_task_pool_work_and_wait(TaskPool *pool)
}
}
-void BLI_pool_set_num_threads(TaskPool *pool, size_t num_threads_max)
+void BLI_pool_set_num_threads(TaskPool *pool, size_t num_threads)
{
/* NOTE: Don't try to modify threads while tasks are running! */
pool->num_threads = num_threads;
More information about the Bf-blender-cvs
mailing list