-
Notifications
You must be signed in to change notification settings - Fork 192
Optimize copy_file
#565
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
Optimize copy_file
#565
Conversation
8e6d9e9 to
3127c3f
Compare
|
FYI @kormide, I think that most of the exec requirements are actually harmful for |
3127c3f to
0ebea4d
Compare
|
I wonder if it would be helpful to have a mechanism to pass in |
You mean on a per-target level (per-mnemonic level is possible with |
4c70b00 to
e5875fd
Compare
* `ctx.actions.symlink` can be used on all platforms and falls back to a copy if a symlink is unsupported. It is also heavily optimized, avoiding the need to hash the output file again. * Bazel never guarantees that an input to an action is staged as a non-symlink, so whether an output is a symlink or a hard copy only matters for top-level outputs consumed outside Bazel and handled by tools that don't follow symlinks by default, which should be extremely rare and could be worked around by explicitly setting `allow_symlink` to `False` in user-controlled code. * For file copy actions that do not go through `ctx.actions.symlink`, caching is extremely cheap since the CAS entry of the input will be reused as the CAS entry of the output. Allowing remote execution and caching enables BwoB for the copy, which can avoid downloads of both the input and the output file. The same changes are not applied to `copy_directory` as source directories are not officially supported by Bazel and any kind of change could cause subtle incorrectness.
e5875fd to
c1fcab0
Compare
tjgq
left a comment
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.
Approved. Rationale: this change is beneficial to many Google-owned (and other) Bazel projects that use skylib. It's also widely used in the Google monorepo.
|
So the idea of this PR is to
Seems reasonable. |
ctx.actions.symlinkcan be used on all platforms and falls back to a copy if a symlink is unsupported. It is also heavily optimized, avoiding the need to hash the output file again.allow_symlinktoFalsein user-controlled code.ctx.actions.symlink, caching is extremely cheap since the CAS entry of the input will be reused as the CAS entry of the output. Allowing remote execution and caching enables BwoB for the copy, which can avoid downloads of both the input and the output file.The same changes are not applied to
copy_directoryas source directories are not officially supported by Bazel before 9 and any kind of change could cause subtle incorrectness.Fixes #562