Make highmem classification of metalava optional
We have added a lot of metalava invocations since the highmem differentation was added, most of which do not use a lot of memory. By collecting data of max rss per process we have narrowed down the set of highmem modules to a smaller set, and will annotate the relevant modules as such. Bug: 170701554 Test: NINJA_HIGHMEM_NUM_JOBS=3 m checkapi (no long tail of metalava) Change-Id: Ic9c8c91388b02889111ef596fc6fd8bde9b42b9d
This commit is contained in:
parent
1e8118da95
commit
52ac73d21e
|
@ -262,6 +262,10 @@ type DroidstubsProperties struct {
|
||||||
// TODO(b/146727827): Remove capability when we do not need to generate stubs and API separately.
|
// TODO(b/146727827): Remove capability when we do not need to generate stubs and API separately.
|
||||||
Generate_stubs *bool
|
Generate_stubs *bool
|
||||||
|
|
||||||
|
// if set to true, provides a hint to the build system that this rule uses a lot of memory,
|
||||||
|
// whicih can be used for scheduling purposes
|
||||||
|
High_mem *bool
|
||||||
|
|
||||||
// is set to true, Metalava will allow framework SDK to contain API levels annotations.
|
// is set to true, Metalava will allow framework SDK to contain API levels annotations.
|
||||||
Api_levels_annotations_enabled *bool
|
Api_levels_annotations_enabled *bool
|
||||||
|
|
||||||
|
@ -1260,8 +1264,6 @@ func (d *Droidstubs) apiLevelsAnnotationsFlags(ctx android.ModuleContext, cmd *a
|
||||||
|
|
||||||
func metalavaCmd(ctx android.ModuleContext, rule *android.RuleBuilder, javaVersion javaVersion, srcs android.Paths,
|
func metalavaCmd(ctx android.ModuleContext, rule *android.RuleBuilder, javaVersion javaVersion, srcs android.Paths,
|
||||||
srcJarList android.Path, bootclasspath, classpath classpath, sourcepaths android.Paths, implicitsRsp android.WritablePath, sandbox bool) *android.RuleBuilderCommand {
|
srcJarList android.Path, bootclasspath, classpath classpath, sourcepaths android.Paths, implicitsRsp android.WritablePath, sandbox bool) *android.RuleBuilderCommand {
|
||||||
// Metalava uses lots of memory, restrict the number of metalava jobs that can run in parallel.
|
|
||||||
rule.HighMem()
|
|
||||||
cmd := rule.Command()
|
cmd := rule.Command()
|
||||||
if ctx.Config().UseRBE() && ctx.Config().IsEnvTrue("RBE_METALAVA") {
|
if ctx.Config().UseRBE() && ctx.Config().IsEnvTrue("RBE_METALAVA") {
|
||||||
rule.Remoteable(android.RemoteRuleSupports{RBE: true})
|
rule.Remoteable(android.RemoteRuleSupports{RBE: true})
|
||||||
|
@ -1343,6 +1345,11 @@ func (d *Droidstubs) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||||
|
|
||||||
rule := android.NewRuleBuilder()
|
rule := android.NewRuleBuilder()
|
||||||
|
|
||||||
|
if BoolDefault(d.properties.High_mem, false) {
|
||||||
|
// This metalava run uses lots of memory, restrict the number of metalava jobs that can run in parallel.
|
||||||
|
rule.HighMem()
|
||||||
|
}
|
||||||
|
|
||||||
generateStubs := BoolDefault(d.properties.Generate_stubs, true)
|
generateStubs := BoolDefault(d.properties.Generate_stubs, true)
|
||||||
var stubsDir android.OptionalPath
|
var stubsDir android.OptionalPath
|
||||||
if generateStubs {
|
if generateStubs {
|
||||||
|
|
|
@ -1232,31 +1232,24 @@ func TestDroiddocArgsAndFlagsCausesError(t *testing.T) {
|
||||||
func TestDroidstubs(t *testing.T) {
|
func TestDroidstubs(t *testing.T) {
|
||||||
ctx, _ := testJavaWithFS(t, `
|
ctx, _ := testJavaWithFS(t, `
|
||||||
droiddoc_exported_dir {
|
droiddoc_exported_dir {
|
||||||
name: "droiddoc-templates-sdk",
|
name: "droiddoc-templates-sdk",
|
||||||
path: ".",
|
path: ".",
|
||||||
}
|
}
|
||||||
|
|
||||||
droidstubs {
|
droidstubs {
|
||||||
name: "bar-stubs",
|
name: "bar-stubs",
|
||||||
srcs: [
|
srcs: ["bar-doc/a.java"],
|
||||||
"bar-doc/a.java",
|
api_levels_annotations_dirs: ["droiddoc-templates-sdk"],
|
||||||
],
|
api_levels_annotations_enabled: true,
|
||||||
api_levels_annotations_dirs: [
|
|
||||||
"droiddoc-templates-sdk",
|
|
||||||
],
|
|
||||||
api_levels_annotations_enabled: true,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
droidstubs {
|
droidstubs {
|
||||||
name: "bar-stubs-other",
|
name: "bar-stubs-other",
|
||||||
srcs: [
|
srcs: ["bar-doc/a.java"],
|
||||||
"bar-doc/a.java",
|
high_mem: true,
|
||||||
],
|
api_levels_annotations_dirs: ["droiddoc-templates-sdk"],
|
||||||
api_levels_annotations_dirs: [
|
api_levels_annotations_enabled: true,
|
||||||
"droiddoc-templates-sdk",
|
api_levels_jar_filename: "android.other.jar",
|
||||||
],
|
|
||||||
api_levels_annotations_enabled: true,
|
|
||||||
api_levels_jar_filename: "android.other.jar",
|
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
map[string][]byte{
|
map[string][]byte{
|
||||||
|
@ -1265,23 +1258,31 @@ func TestDroidstubs(t *testing.T) {
|
||||||
testcases := []struct {
|
testcases := []struct {
|
||||||
moduleName string
|
moduleName string
|
||||||
expectedJarFilename string
|
expectedJarFilename string
|
||||||
|
high_mem bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
moduleName: "bar-stubs",
|
moduleName: "bar-stubs",
|
||||||
expectedJarFilename: "android.jar",
|
expectedJarFilename: "android.jar",
|
||||||
|
high_mem: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
moduleName: "bar-stubs-other",
|
moduleName: "bar-stubs-other",
|
||||||
expectedJarFilename: "android.other.jar",
|
expectedJarFilename: "android.other.jar",
|
||||||
|
high_mem: true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, c := range testcases {
|
for _, c := range testcases {
|
||||||
m := ctx.ModuleForTests(c.moduleName, "android_common")
|
m := ctx.ModuleForTests(c.moduleName, "android_common")
|
||||||
metalava := m.Rule("metalava")
|
metalava := m.Rule("metalava")
|
||||||
|
rp := metalava.RuleParams
|
||||||
expected := "--android-jar-pattern ./%/public/" + c.expectedJarFilename
|
expected := "--android-jar-pattern ./%/public/" + c.expectedJarFilename
|
||||||
if actual := metalava.RuleParams.Command; !strings.Contains(actual, expected) {
|
if actual := rp.Command; !strings.Contains(actual, expected) {
|
||||||
t.Errorf("For %q, expected metalava argument %q, but was not found %q", c.moduleName, expected, actual)
|
t.Errorf("For %q, expected metalava argument %q, but was not found %q", c.moduleName, expected, actual)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if actual := rp.Pool != nil && strings.Contains(rp.Pool.String(), "highmem"); actual != c.high_mem {
|
||||||
|
t.Errorf("Expected %q high_mem to be %v, was %v", c.moduleName, c.high_mem, actual)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue