Graph trimming and remote caching

34 views
Skip to first unread message

Konstantin

unread,
Mar 28, 2024, 1:54:52 PMMar 28
to bazel-discuss
This conversation from four years ago suggests that graph trimming with unused_inputs_list attribute to ctx.actions.run() hurts remote caching as the cache key is constructed from all declared inputs instead of only used ones. I wonder if it is still the case and what can possibly be done to make it work.
C++ compilation rules use unused_inputs_list to remove unused headers from the list of compilation action inputs and it seriously harms remote caching efficiency. Looking for a workaround. 

Any thoughts?
Konstantin

Yannic

unread,
Mar 29, 2024, 12:20:26 PMMar 29
to bazel-discuss
Hey Konstantin,

At least for C++, using declared inputs to compute the cache key is mandatory for correctness. One can use __has_include() to change the behavior of programs depending on the pure existence of a declared input. Please see this example: https://github.com/bazelbuild/bazel/pull/13592#issuecomment-976694722

Thanks,
Yannic
Reply all
Reply to author
Forward
0 new messages