idaholab / moose

Multiphysics Object Oriented Simulation Environment
https://www.mooseframework.org
GNU Lesser General Public License v2.1
1.77k stars 1.05k forks source link

Limit number of files to merge together in unity build #27869

Open hugary1995 opened 5 months ago

hugary1995 commented 5 months ago

Motivation

Unity build is great. But over the years the unity files are growing larger and larger. It is now at a point where certain unity files are too big. For example the materials_unity in the solid mechanics module and the userobjects_unity in the framework.

Design

The solid mechanics module addresses this issue by splitting up the materials directory into sub-directories. While I think that is a valid approach, a framework-level more general approach could be to limit the number of files to "unify". CMake has a similar option UNITY_BUILD_BATCH_SIZE. It would be nice if we can support something like that.

Impact

Faster iteration while developing. For example if I only modify a single source file, I would only have to recompile a subset of the userobjects_unity file.

GiudGiud commented 5 months ago

This is a good idea. The default size could be chosen based on how much memory one has on their system too, with a rough heuristic.

hugary1995 commented 5 months ago

Yeah, that's a good point. This could offer finer control for machines with less memory, instead of going all the way to MOOSE_UNITY=0.