Skip to content

Update only when different for several harvester scripts#603

Open
ChrisJChang wants to merge 3 commits into
GambitBSM:masterfrom
ChrisJChang:claude/optimistic-pascal-o2wsbg
Open

Update only when different for several harvester scripts#603
ChrisJChang wants to merge 3 commits into
GambitBSM:masterfrom
ChrisJChang:claude/optimistic-pascal-o2wsbg

Conversation

@ChrisJChang

Copy link
Copy Markdown
Collaborator

This PR writes a few scratch build files for the results of some of the harvester scripts, and checks whether they are different before updating the files. The purpose of this is that when rerunning cmake, we want to avoid rebuilding files that aren't actually any different.

My test for this was running a build, running cmake .. (with no code changes at all), and rerunning make again to see what still builds. This reduces it quite a bit, but there are still a few files that rebuild. There are few enough that I do not think it is too much of a problem. These are SpecBit files that are being built because there is a FlexibleSUSY configure script that is generating some config header (only included in SpecBit files). I can try to solve that in another PR if desired.

claude added 3 commits June 11, 2026 09:20
Write ColliderBit_models_rollcall.hpp and Py8Collider_typedefs.hpp to
candidate files and install them with update_only_if_different(), as the
other harvesters already do. Previously these two headers were rewritten
unconditionally (with a fresh timestamp) every time the harvester ran,
which dirtied ColliderBit_rollcall.hpp/ColliderBit_types.hpp and forced
a large ColliderBit and Core rebuild after every reconfiguration even
when nothing had changed.

https://claude.ai/code/session_01QaXhcsFuD88dDh7Qvq1pSA
The harvester custom commands (and the standalone functor facilitator)
depended on CMakeCache.txt, so every rerun of cmake caused all of them
to run again at the next make. Replace that dependency with a stamp
file recording the full harvester command line, updated at configure
time via copy_if_different. The harvesters still rerun when their
inputs, the -Ditch list, or the Python interpreter change, but no
longer after a no-op reconfigure.

https://claude.ai/code/session_01QaXhcsFuD88dDh7Qvq1pSA
Two remaining causes of mass rebuilds after a cmake rerun:

1. backend_harvester.py, model_harvester.py, particle_harvester.py and
   make_module_rollcall() in harvesting_tools.py wrote their outputs
   unconditionally, dirtying backend_rollcall.hpp,
   backend_types_rollcall.hpp, model_rollcall.hpp,
   model_types_rollcall.hpp, particle_database.cpp and
   module_rollcall.hpp on every harvester run. Route them all through
   update_only_if_different(), as module_harvester.py already does.
   Since backend and model types are included by nearly every GAMBIT
   source file, this alone forced a near-full rebuild whenever the
   harvesters re-ran.

2. The harvesters emit include lists and template instantiations by
   iterating over Python sets, whose iteration order changes between
   interpreter invocations due to hash randomisation. This made the
   generated files differ from run to run, defeating
   update_only_if_different() even where it was already used. Sort all
   set-based collections at the point of emission so the generated
   content is deterministic.

With this, rerunning the harvesters (e.g. after any cmake
reconfiguration, which deletes their stamp files) leaves all twelve
generated files untouched unless their content genuinely changes.

https://claude.ai/code/session_01QaXhcsFuD88dDh7Qvq1pSA
@ChrisJChang ChrisJChang requested a review from anderkve June 11, 2026 11:51
@ChrisJChang ChrisJChang self-assigned this Jun 11, 2026
@ChrisJChang ChrisJChang added build Core Core group task labels Jun 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build Core Core group task

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants