-
Notifications
You must be signed in to change notification settings - Fork 145
perf: Speedup root_relative_path #509
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
base: main
Are you sure you want to change the base?
Conversation
cc/common/cc_helper_internal.bzl
Outdated
| """ | ||
| if not file.is_source: | ||
| if file.path.startswith(file.root.path + "/"): | ||
| # TODO(zbarsky): is this always the case? |
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.
I think that this should always be true and we can unconditionally strip the root path with slash. But I wanted to guarantee parity with the former native implementation, which did this.
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.
I don't have a strong opinion, though I think as-written the PR is guaranteed not to change the behavior because it checks before stripping. Simplifying it to just strip and dropping the lines below would be a pretty minimal speedup compared to what this already achieves
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.
I can approve this if you can do some double checking so we can confidently remove this TODO.
Edit: Or update the comment to include reasons/sources of uncertainty.
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.
I also feel like this should always be true but wasn't sure if Google had any internal weirdness that made the previous impl necessary - didn't want to mix a perf improvement with a potential semantic change. But given the import process will make sure google3 is happy anyway, we can give it a shot! Updated
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.
https://github.com/bazelbuild/bazel/blob/8eaf6a90db1d0e95fbade4dd2b7e3b8c57d03629/src/main/java/com/google/devtools/build/lib/actions/Artifact.java#L308 should be proof that this is always correct - the call would crash if it isn't.
210737e to
0119ae8
Compare
Before:

After:
