On Fri, 19 Dec 2025 18:29:43 GMT, Kevin Rushforth <[email protected]> wrote:

> This PR adds a new `MAX_COMPILE_THREADS` gradle property to to limit the 
> number of build-time parallel compilation threads to the smaller of this 
> property and the number of avialable processors.
> 
> Our gradle build spawns up to `NUM_COMPILE_THREADS` compilation tasks in 
> parallel when building native libraries. By default, `NUM_COMPILE_THREADS` is 
> set to the value returned by `Runtime.getRuntime().availableProcessors()`. 
> That value can be overridden on the command line by setting the 
> `NUM_COMPILE_THREADS` gradle property. We need a way to clamp 
> `NUM_COMPILE_THREADS` at some maximum value without the caller having to 
> compute it.
> 
> The change in `build.gradle` is simple:
> 
> * Define a new `MAX_COMPILE_THREADS` gradle property, which will default to 0 
> (meaning unlimited) for compatibility with current behavior.
> 
> * Set the default value of `NUM_COMPILE_THREADS` as follows:
> 
> 
>     NUM_COMPILE_THREADS = MAX_COMPILE_THREADS > 0
>                         ? Math.min(MAX_COMPILE_THREADS, availableProcessors)
>                         : availableProcessors(
> 
> 
> This will allow a test scripts that runs on a number of different platforms 
> to clamp to a maximum value without having to use jshell or similar to 
> implement `Math.min(MAX_COMPILE_THREADS, 
> Runtime.getRuntime().availableProcessors())` in the script.
> 
> We have a practical need for this in our headful test systems, several of 
> which report a higher number of processors than they can effectively support. 
> Without clamping, the build will either run slower (due to too much swapping) 
> or fail altogether when building WebKit.

This pull request has now been integrated.

Changeset: 1e6c94b3
Author:    Kevin Rushforth <[email protected]>
URL:       
https://git.openjdk.org/jfx/commit/1e6c94b3c46db66df5856183859e05a683d1249a
Stats:     23 lines in 2 files changed: 20 ins; 0 del; 3 mod

8374153: Add a MAX_COMPILE_THREADS gradle property to limit number of threads

Reviewed-by: arapte, hmeda

-------------

PR: https://git.openjdk.org/jfx/pull/2014

Reply via email to