-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Introduce --local_resources flag #20398
Introduce --local_resources flag #20398
Conversation
cc @zhengwei143 |
@@ -294,6 +294,8 @@ public boolean shouldMaterializeParamFiles() { | |||
@Option( | |||
name = "local_cpu_resources", | |||
defaultValue = "HOST_CPUS", |
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 there a way to keep using these variables in --local_resources
? That would be worth documenting in the flag's description.
Also, what is going to happen to the default values for cpu
and memory
?
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 there a way to keep using these variables in --local_resources? That would be worth documenting in the flag's description.
Aah, good point. I've refactored a bit the converter to support both integers and doubles and added support for HOST_CPUS and HOST_RAM
Also, what is going to happen to the default values for cpu and memory?
Once --local_{cpu,ram}_resources
are deprecated and removed, they should probably be moved here. I've added a comment as a reminder.
a9d099b
to
74225e4
Compare
74225e4
to
620a249
Compare
@@ -39,7 +41,83 @@ | |||
* <p>The supplier of the auto value, and, optionally, a max or min allowed value (inclusive), are | |||
* passed to the constructor. | |||
*/ | |||
public class ResourceConverter extends Converters.IntegerConverter { | |||
public abstract class ResourceConverter<T extends Number & Comparable<T>> extends Converter.Contextless<T> { | |||
public static final Supplier<Integer> HOST_CPUS = |
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.
Nit: Rename to HOST_CPUS_SUPPLIER
. Similarly to HOST_RAM_SUPPLIER
below.
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.
Done
private static final ResourceConverter.DoubleConverter resource = | ||
new ResourceConverter.DoubleConverter( | ||
ImmutableMap.of( | ||
"HOST_CPU", () -> (double) HOST_CPUS.get(), |
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.
Nit: Refactor "HOST_CPU"
and "HOST_RAM"
into a static String variables.
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.
Done
() -> (int) Math.ceil(LocalHostCapacity.getLocalHostCapacity().getMemoryMb())), | ||
/* minValue= */ 0, | ||
/* maxValue= */ Integer.MAX_VALUE); | ||
super(ImmutableMap.of("HOST_RAM", HOST_RAM), 0, Integer.MAX_VALUE); |
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.
Nit: Add /* minValue= */
comments for argument 0
since it isn't immediately obvious. Same as for all other similar changes.
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.
Done
src/main/java/com/google/devtools/build/lib/buildtool/ExecutionTool.java
Show resolved
Hide resolved
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.
LGTM!
@zhengwei143 @keertk any blocker for this to land? |
Hi, drive-by comment, I've been on vacation and will be till the start of next year - so will push this through when I'm back then. |
@AlessandroPatti Sorry this took so long due to the holidays, thanks for your contribution! |
@bazel-io fork 7.1.0 |
Follow up for bazelbuild#19839 (comment), introduce new flag that will replace all the others. Closes bazelbuild#20398. PiperOrigin-RevId: 596905096 Change-Id: Ic2c20dae40efa797953cde6934085f899acb9b52
Follow up for #19839 (comment), introduce new flag that will replace all the others. Closes #20398. Commit ea75928 PiperOrigin-RevId: 596905096 Change-Id: Ic2c20dae40efa797953cde6934085f899acb9b52 Co-authored-by: Alessandro Patti <[email protected]>
Follow up for bazelbuild#19839 (comment), introduce new flag that will replace all the others. Closes bazelbuild#20398. PiperOrigin-RevId: 596905096 Change-Id: Ic2c20dae40efa797953cde6934085f899acb9b52
Follow up for bazelbuild#19839 (comment), introduce new flag that will replace all the others. Closes bazelbuild#20398. PiperOrigin-RevId: 596905096 Change-Id: Ic2c20dae40efa797953cde6934085f899acb9b52
The changes in this PR have been included in Bazel 7.1.0 RC1. Please test out the release candidate and report any issues as soon as possible. If you're using Bazelisk, you can point to the latest RC by setting USE_BAZEL_VERSION=last_rc. |
Follow up for #19839 (comment), introduce new flag that will replace all the others.