Skip to content

Fix the combination preprocessor cache mode + distributed compilation #2392

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

ahartmetz
Copy link
Contributor

No description provided.

@ahartmetz ahartmetz marked this pull request as draft May 6, 2025 12:54
@codecov-commenter
Copy link

codecov-commenter commented May 6, 2025

Codecov Report

Attention: Patch coverage is 76.41026% with 46 lines in your changes missing coverage. Please review.

Project coverage is 66.92%. Comparing base (7025295) to head (b813cb8).

Files with missing lines Patch % Lines
src/compiler/gcc.rs 37.50% 20 Missing ⚠️
src/compiler/compiler.rs 65.85% 14 Missing ⚠️
src/compiler/nvcc.rs 0.00% 4 Missing ⚠️
src/compiler/nvhpc.rs 0.00% 4 Missing ⚠️
src/compiler/rust.rs 94.82% 3 Missing ⚠️
src/compiler/c.rs 98.18% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2392      +/-   ##
==========================================
- Coverage   67.06%   66.92%   -0.15%     
==========================================
  Files          64       64              
  Lines       34718    34586     -132     
==========================================
- Hits        23285    23145     -140     
- Misses      11433    11441       +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sylvestre
Copy link
Collaborator

nice
a few jobs are failing btw

@ahartmetz ahartmetz force-pushed the fix_direct_mode_distributed branch from 100c577 to 422cf17 Compare May 13, 2025 14:12
@ahartmetz
Copy link
Contributor Author

This seems really annoying to auto-test, and to be honest, I haven't even tested it manually yet ;)
I will obviously need to do at least that.

ahartmetz added 4 commits May 18, 2025 13:32
It will need to call itself (in the next commit), and the
"consumes and moves values out of the instance" model doesn't
work for that.
...and disable the workaround that disabled the former in case of
the latter.
Under the following conditions:
- Build with preprocessor cache mode enabled
- Distributed build
- Preprocessor cache hit
- Main cache miss
the compile that was run as "fallback" after the cache miss did
not have preprocessed sources passed to it since skipping the
preprocessing step is the whole point of preprocessor cache mode.
But local preprocessing is what enables distributed compilation.
To fix this, when the problem occurs, recursively re-invoke
get_cached_or_compile() with ForceRecache(*) so that the
preprocessor cache hit is (mostly) ignored, which makes
get_cached_or_compile() invoke the local preprocessing codepath,
which yields code suitable for distributed compilation.

(*) which also prevents further recursion
This reverts the "main" code changes of commit
c0a0b6e but keeps the added test.

A better fix will work as follows:
- Always store the dep file in the cache
- In non-preprocessor cache mode, which doesn't consider things
  like file name and included file names, so it can confuse cache
  entries with same preprocessed content but different dep files:
  do not restore the dep file. It is not necessary anyway because
  local preprocessing will produce the file.
- In preprocessor cache mode, which uses input file names and
  hashes to distinguish cache entries, but does not run the
  preprocessor:
  *do* restore the dep file.
@ahartmetz ahartmetz force-pushed the fix_direct_mode_distributed branch from 422cf17 to d97d906 Compare May 18, 2025 19:53
@ahartmetz
Copy link
Contributor Author

ahartmetz commented May 18, 2025

So I did do some practical testing and ran into another blocker for preprocessor cache mode, this time that it didn't work with -MD (which is used by at least Make and Ninja backends of CMake, so very widely I'd say).
@glandium, do the last three commits look reasonable to you?

It is curious that
#2194
is older than
#2322
so it seems like there is another, yet unfixed, bug that breaks caching and restoring .d files in preprocessor cache mode?

@ahartmetz ahartmetz force-pushed the fix_direct_mode_distributed branch from d97d906 to b813cb8 Compare May 18, 2025 23:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants