Skip to content
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

Starlark API to allow rules and genrules to declare ResourceSets #8107

Closed
wants to merge 1 commit into from
Closed

Starlark API to allow rules and genrules to declare ResourceSets #8107

wants to merge 1 commit into from

Conversation

ghost
Copy link

@ghost ghost commented Apr 21, 2019

This change allows rule writers to define CPU and memory requirements for
rules. It's intended to help avoid overcommitting a build host when
invoking multithreaded or memory-intensive commands.

The approach taken was discussed both in #6477 and
https://groups.google.com/d/msg/bazel-dev/HaZuVmx6dfk/h6WnlabHCQAJ.

In a future change, TaggedRequirement could replace (and be renamed
to) ParseableRequirement.

Resolves #6477.

@aiuto aiuto requested a review from c-parsons April 22, 2019 18:32
@c-parsons c-parsons requested review from buchgr and lberki and removed request for c-parsons April 23, 2019 16:26
@c-parsons c-parsons added team-Local-Exec Issues and PRs for the Execution (Local) team and removed team-Starlark labels Apr 23, 2019
@c-parsons
Copy link
Contributor

This doesn't quite belong under Starlark team IMO. The "API change" itself doesn't constitute much of a Starlark semantic change -- it simply expands the set of meaningful action execution requirements (all strings are accepted, I believe, but only some strings have meaning. this is increasing the list of strings which have meaning).

(FWIW, this change in Starlark seems fine, but I don't know about the ramifications of the rest of the code)

CC @buchgr and @lberki

@jin
Copy link
Member

jin commented Apr 23, 2019

team-Local-Exec is managed by @jmmv according to https://www.bazel.build/maintainers-guide.html#team-labels

@jin jin assigned jmmv Apr 23, 2019
Copy link
Contributor

@jmmv jmmv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for doing this! Just today I was talking to someone and saying that this feature existed but wasn't exposed to Starlark, so this is very timely.

*/
public ValidationException(String tagValue, String errorMsg) {
super(errorMsg);
this.tagValue = tagValue;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we guarantee in some way that the error message contains the tag value?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question. I can go in either direction, but I'd like to point out that this is copied/pasted from ParseableRequirement.ValidationException. Similarly, the error handler in SkylarkActionFactory.java is directly influenced by the one from TestTargetProperties.java.

What's the dominant convention? (Throwers of InvalidPackageNameException don't include bad values in their error message, while throwers of EvalException sometimes do.)


/** Integer validator to use with {@link ParseableRequirement} and {@link TaggedRequirement}. */
private static String IntegerValidator(String s) {
Preconditions.checkNotNull(s);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When would we expect this to be null? I think never, so it's fair to assume it's not null and let the code below crash if it is.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a traveler in a foreign codebase, I'm totally okay with removing it, but that check predates me, fwiw. (See da21ba7.)

@jmmv jmmv added P2 We'll consider working on this in future. (Assignee optional) type: feature request and removed untriaged labels Apr 24, 2019
@jmmv
Copy link
Contributor

jmmv commented Apr 24, 2019

CC @sergiocampama @thomasvl

This change allows rule writers to define CPU and memory requirements for
rules.  It's intended to help avoid overcommitting a build host when
invoking multithreaded or memory-intensive commands.

The approach taken was discussed both in #6477 and
https://groups.google.com/d/msg/bazel-dev/HaZuVmx6dfk/h6WnlabHCQAJ.

In a future change, `TaggedRequirement` could replace (and be renamed
to) `ParseableRequirement`.

Resolves #6477.
@ghost
Copy link
Author

ghost commented Sep 4, 2019

@jmmv Can we please revisit this? You provided some feedback which I responded to with some clarifying questions of my own. It'd be nice if this (or something better) were accepted into 1.0.

@laurentlb
Copy link
Contributor

@jmmv What's the status of this?
Is there anything blocking?

@tetromino
Copy link
Contributor

@jmmv - ping for review

@ghost
Copy link
Author

ghost commented Mar 18, 2020

It looks like Action Groups supersedes this? (Proposal: https://docs.google.com/document/d/1m9xLRLg09lncQTuBUMhhG_lqDQGJRYMZPejvwdBXvqo/edit#heading=h.5mcn15i0e1ch ; search for exec_properties and requires-mem.)

cc @juliexxia

@ghost
Copy link
Author

ghost commented Mar 18, 2020

Sorry for the bogus cc; my attention is split atm. (Julie commented on the parent issue.)

Since Action Groups w/ exec properties is underway, I'm going to discard this.

@ghost ghost closed this Mar 18, 2020
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes P2 We'll consider working on this in future. (Assignee optional) team-Local-Exec Issues and PRs for the Execution (Local) team type: feature request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

API for Skylark rules and genrules to declare ResourceSets
8 participants