On Mon, 19 Oct 2026 23:29:33 GMT, Benjamin Peterson <[email protected]> 
wrote:

> For every spawn, GNU make iterates all variables to find the exported ones. 
> The JDK build has many variables and many spawns, so a significant fraction 
> of make's CPU time is iterating variables during a JDK build.
> 
> This change undefines variables from two frequently used macros, 
> SetupNativeCompilationBody and CreateCompiledNativeFileBody, after the 
> variables are no longer needed.
> 
> This simple change removes 60% of the variables from the JtregNativeHotspot 
> submake and 55% of make variables from the hotspot submake. Overall, this 
> saves 38% of make CPU time on a clean build to run one jtreg test.
> 
> 
> 
> 
> ---------
> - [x] I confirm that I make this contribution in accordance with the [OpenJDK 
> Interim AI Policy](https://openjdk.org/legal/ai).

This is an interesting idea. I wasn't aware of this inefficiency in GNU Make. 
The actual impact on complete build times is  a bit more modest than you are 
implying. With GNU Make 4.0 I'm seeing no practical improvement (tried clean 
runs of make hotspot). With 4.4.1, which seems to be more sensitive to this 
optimization, there seems to be some measurable improvement for a real clean 
build. I don't have enough samples to give a reliable number however, but it's 
in the single digit %.

I also took the patch through COMPARE_BUILD runs on all our supported platforms 
to make sure no important variable was lost. Those were successful.

My concern is maintaining these lists of variables long term. It adds another 
level of complexity on already quite complex makefiles. I think I can be ok 
with it, but would like input from more build group people and OpenJDK 
developers in general to gauge the actual impact of this change to see if it's 
worth the trouble.

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

PR Comment: https://git.openjdk.org/jdk/pull/33454#issuecomment-6298300198

Reply via email to