mirror of
				https://github.com/Zygo/bees.git
				synced 2025-11-03 19:50:34 +01:00 
			
		
		
		
	bees: soft-limit computed thread counts to 8
https://github.com/Zygo/bees/issues/91 describes problems encountered when running bees on systems with many CPU cores. Limit the computed number of threads (using --thread-factor or the default) to a maximum of 8 (i.e. the number of logical cores in a modern laptop). Users can override the limit by using --thread-count. Signed-off-by: Zygo Blaxell <bees@furryterror.org>
This commit is contained in:
		@@ -786,6 +786,11 @@ bees_main(int argc, char *argv[])
 | 
			
		||||
			thread_factor = BEES_DEFAULT_THREAD_FACTOR;
 | 
			
		||||
		}
 | 
			
		||||
		thread_count = max(1U, static_cast<unsigned>(ceil(thread::hardware_concurrency() * thread_factor)));
 | 
			
		||||
		if (thread_count > BEES_DEFAULT_THREAD_LIMIT) {
 | 
			
		||||
			BEESLOGNOTICE("Limiting computed thread count to " << BEES_DEFAULT_THREAD_LIMIT);
 | 
			
		||||
			BEESLOGNOTICE("Use --thread-count to override this limit");
 | 
			
		||||
			thread_count = BEES_DEFAULT_THREAD_LIMIT;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (load_target != 0) {
 | 
			
		||||
 
 | 
			
		||||
@@ -85,6 +85,9 @@ const size_t BEES_OPEN_FILE_LIMIT = (BEES_FILE_FD_CACHE_SIZE + BEES_ROOT_FD_CACH
 | 
			
		||||
// Worker thread factor (multiplied by detected number of CPU cores)
 | 
			
		||||
const double BEES_DEFAULT_THREAD_FACTOR = 1.0;
 | 
			
		||||
 | 
			
		||||
// Don't use more than this number of threads unless explicitly configured
 | 
			
		||||
const size_t BEES_DEFAULT_THREAD_LIMIT = 8;
 | 
			
		||||
 | 
			
		||||
// Log warnings when an operation takes too long
 | 
			
		||||
const double BEES_TOO_LONG = 5.0;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user