Backport !77848 (merged) to 24.0 as it may help with job efficiency also there.
There may be conflicts when sweeping to main and the main version should always be taken (cc @tsulaia, @wlampl).