-
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
Automatically map paths in Args#map_each
#19723
Conversation
Stacked on #19717 |
08a4169
to
a801bf7
Compare
@lberki Could you review the second commit? This is what we talked about at BazelCon 2022 (I know, it's been a while :-) ). I settled on an approach where every access to relevant |
// It would *not* be correct to just apply PathMapper#map to the exec path of the root: The | ||
// root part of the mapped exec path of this artifact may depend on its complete exec path as | ||
// well as on e.g. the digest of the artifact. | ||
PathFragment mappedExecPath = PathMapper.loadFrom(semantics).map(execPath); |
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.
@lberki Would you expect the load from semantics to matter CPU-wise? If so, I could implement two versions of the function that are alternated between based on a semantics flag.
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.
My professional opinion is that I don't know. What I think is that this shouldn't matter much, because it's not called in a very tight loop and thus an extra map lookup, say, per dependency edge shouldn't matter much. When in doubt, I'd rather err on the side of simple code.
New thread, who dis? :) More seriously, I haven't been following the story of
If this idea proves to be bad, reverting it and going with (1) or (2) would cost the same as doing them right now, wouldn't it?
|
Yes, I think so :-) Plus only real-world usage will tell which approach is ultimately better.
I would argue that the intersection is about as large as the "wants path mapping" set itself: If you want path mapping for a realistically complicated action, you will have to use |
fabfd8c
to
dbedc66
Compare
@gregestren @aranguyen This is no longer stacked and ready for review. |
9cfbb95
to
670f1b3
Compare
@fmeum Speaking of priority for our presentation, since #19717 is merged and considering your comment here #19717 (comment), do we need this merged in order for us to do some demo with rules go? If not, I do want to spend a bit more time on #18098 (comment) |
Yeah, let's solve the issue that came up over at #18098 first. The current PR is required to proclaim general Starlark support and invite ruleset authors to pick it up, which would be pretty nice, but isn't a hard requirement as some Starlark actions will still qualify. |
Not sure where I previously mentioned issue regarding paths get mapped multiple times which results in wrong path with missing |
I think I can resolve this by introducing the fixed |
by fixed |
@aranguyen Yes, exactly. in addition to improved compatibility, this also gives us a way to more easily |
src/test/java/com/google/devtools/build/lib/analysis/actions/StrippingPathMapperTest.java
Show resolved
Hide resolved
3bcf76c
to
fb72613
Compare
@aranguyen I talked to Ivo offline and learned that lazy depset transformations may not be coming soon after all. Instead, I would add a This can wait for a separate PR though. |
When path mapping is enabled, `File` objects accessed in a user-supplied callback passed to `Args#map_each` automatically have their paths mapped. Automatic rewriting is preferable to e.g. passing a rewriter object into the callback: All paths emitted into command lines must be rewritten with path mapping as inputs and outputs are staged at the mapped locations, so the user would need to manually map all paths - there is no choice. As an added benefit, the automatic rewriting ensures that existing rules relying on `map_each` do not need to be modified to use path mapping.
fb72613
to
2c83949
Compare
@fmeum I fixed the merge conflict internally and will send this out for internal review soon. |
@aranguyen It looks like this broke the GitHub checks. Do you want me to fix them here? |
@bazel-io fork 7.2.0 |
When path mapping is enabled, `File` objects accessed in a user-supplied callback passed to `Args#map_each` automatically have their paths mapped. Automatic rewriting is preferable to e.g. passing a rewriter object into the callback: All paths emitted into command lines must be rewritten with path mapping as inputs and outputs are staged at the mapped locations, so the user would need to manually map all paths - there is no choice. As an added benefit, the automatic rewriting ensures that existing rules relying on `map_each` do not need to be modified to use path mapping. As part of this change, `PathMapper` has to become an abstract class as interfaces can't override `equals` and `hashCode`. Work towards bazelbuild#6526 Closes bazelbuild#19723. PiperOrigin-RevId: 621972618 Change-Id: If76e5beee86a354aa97cb3000315b75b2ed24028
When path mapping is enabled,
File
objects accessed in a user-supplied callback passed toArgs#map_each
automatically have their paths mapped.Automatic rewriting is preferable to e.g. passing a rewriter object into the callback: All paths emitted into command lines must be rewritten with path mapping as inputs and outputs are staged at the mapped locations, so the user would need to manually map all paths - there is no choice. As an added benefit, the automatic rewriting ensures that existing rules relying on
map_each
do not need to be modified to use path mapping.As part of this change,
PathMapper
has to become an abstract class as interfaces can't overrideequals
andhashCode
.Work towards #6526