-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Fix issues with path mapping in map_each
functions
#22227
Conversation
map_each
functions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fmeum thank you for the pr and I'm so sorry for the late review. I added a few questions and just have a general concern with having a distinct PathMapper just for fingerprinting and a different PathMapper? for mapping the command line inputs & for usage on the executors. I don't have a good suggestion to solve the issue at the moment but would like to discuss this further in one of our next meetings
Do we have reported failures that are related to this? It would be great to have these documented.
I LGTM this for now to get this imported and tested internally in parallel.
* <li>Unconditionally using {@link StrippingPathMapper} can result in stale action keys when an | ||
* action is opted out of path mapping at execution time due to input path collisions after | ||
* stripping. See path_mapping_test for an example. | ||
* <li>Using {@link PathMapper#NOOP} does not distinguish between map_each results built from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this because FileApi.getExecPathStringForStarlark
still needed for things that are not opted in with map_each
? Just wondering if we can merge them to get rid of the difference in behavior
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't get rid of the difference in this situation since File#path
only returns the correct result when used in a map_each
callback. If someone e.g. keeps paths as strings around in providers and then migrates to artifacts to become compatible with path mapping, they may run into this staleness (without this fix).
* the input depsets of all actions that opt into path mapping and also increases CPU usage. | ||
* <li>Unconditionally using {@link StrippingPathMapper} can result in stale action keys when an | ||
* action is opted out of path mapping at execution time due to input path collisions after | ||
* stripping. See path_mapping_test for an example. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have a real use case for this one? How did you discover this issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This issue is more of an edge case and I only discovered it when I tried to think through whether our fingerprinting scheme is sound in all cases.
Hello @fmeum, Could you please resolve the above code conflicts. Thanks! |
@sgowroji I resolved the conflicts |
@bazel-io flag |
@bazel-io fork 7.4.0 |
@fmeum Is this a necessary fix to try various C++ path mapping changes in upcoming 7.3 release? |
@nikhilkalige No, the basics work without it. See #22658 for the exact missing features. |
Fixes the following issues with path mapping applied to `map_each` functions: * Action keys could be stale if an action implementation switches from hard-coded artifact strings to `File`s mapped at execution time. This commit introduces a special `PathMapper` instance for fingerprinting, see the long comment on `PathMappers.FOR_FINGERPRINTING`. It includes a number of tests to verify that neither too much nor too little is mapped during action key computation. * The Starlark objects representing mapped artifact roots didn't have the correct semantics for equality and ordered comparisons. They are now unequal to unmapped roots. * When not using path mapping, the `StarlarkSemantics` of a thread used to evaluate `map_each` callbacks is not modified. These changes require splitting `PathMappers` out of `analysis_cluster` and also make `StrippingPathMapper` a subclass of `PathMapper` instead of using an anonymous one. Closes bazelbuild#22227. PiperOrigin-RevId: 657449600 Change-Id: If949d23acab163cb192ea3af1baeb7a3caca7339
Fixes the following issues with path mapping applied to `map_each` functions: * Action keys could be stale if an action implementation switches from hard-coded artifact strings to `File`s mapped at execution time. This commit introduces a special `PathMapper` instance for fingerprinting, see the long comment on `PathMappers.FOR_FINGERPRINTING`. It includes a number of tests to verify that neither too much nor too little is mapped during action key computation. * The Starlark objects representing mapped artifact roots didn't have the correct semantics for equality and ordered comparisons. They are now unequal to unmapped roots. * When not using path mapping, the `StarlarkSemantics` of a thread used to evaluate `map_each` callbacks is not modified. These changes require splitting `PathMappers` out of `analysis_cluster` and also make `StrippingPathMapper` a subclass of `PathMapper` instead of using an anonymous one. Closes #22227. PiperOrigin-RevId: 657449600 Change-Id: If949d23acab163cb192ea3af1baeb7a3caca7339 Closes #22227
The changes in this PR have been included in Bazel 7.4.0 RC1. Please test out the release candidate and report any issues as soon as possible. |
Fixes the following issues with path mapping applied to
map_each
functions:File
s mapped at execution time. This commit introduces a specialPathMapper
instance for fingerprinting, see the long comment onPathMappers.FOR_FINGERPRINTING
. It includes a number of tests to verify that neither too much nor too little is mapped during action key computation.StarlarkSemantics
of a thread used to evaluatemap_each
callbacks is not modified.These changes require splitting
PathMappers
out ofanalysis_cluster
and also makeStrippingPathMapper
a subclass ofPathMapper
instead of using an anonymous one.