File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change 4141 * @CHAFA_FEATURE_AVX2: Flag indicating AVX2 support.
4242 **/
4343
44+ /* The detected CPU count can approach 200 in realistic environments (64 on
45+ * UltraSparc T2, 192 on Ryzen Threadripper Pro), and mapped memory may be
46+ * limited to as little as 1.5GB (default RLIMIT_DATA on OpenBSD 7.8/sparc64 -
47+ * malloc's MAXDSIZ is set to 8GB). Keep a sensible thread limit to avoid
48+ * running out of memory. */
49+ #define AUTO_THREAD_COUNT_MAX 24
50+
4451static gboolean chafa_initialized ;
4552
4653static gboolean have_mmx ;
@@ -261,8 +268,13 @@ chafa_get_n_actual_threads (void)
261268 gint n_actual_threads ;
262269
263270 n_actual_threads = chafa_get_n_threads ();
271+
264272 if (n_actual_threads < 0 )
273+ {
265274 n_actual_threads = g_get_num_processors ();
275+ n_actual_threads = MIN (n_actual_threads , AUTO_THREAD_COUNT_MAX );
276+ }
277+
266278 if (n_actual_threads <= 0 )
267279 n_actual_threads = 1 ;
268280
You can’t perform that action at this time.
0 commit comments