Merge "Shard srcjars when sharding javac compilation" into main am: b983ceac33 am: 9a21f40742

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2762551

Change-Id: Iab092236065583a885abddac58505e0ff79a66ef
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Colin Cross 2023-09-26 19:20:40 +00:00 committed by Automerger Merge Worker
commit e693d617c2

View file

@ -1343,10 +1343,17 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath
jars = append(jars, classes)
}
}
// Assume approximately 5 sources per srcjar.
// For framework-minus-apex in AOSP at the time this was written, there are 266 srcjars, with a mean
// of 5.8 sources per srcjar, but a median of 1, a standard deviation of 10, and a max of 48 source files.
if len(srcJars) > 0 {
classes := j.compileJavaClasses(ctx, jarName, len(shardSrcs),
nil, srcJars, flags, extraJarDeps)
jars = append(jars, classes)
startIdx := len(shardSrcs)
shardSrcJarsList := android.ShardPaths(srcJars, shardSize/5)
for idx, shardSrcJars := range shardSrcJarsList {
classes := j.compileJavaClasses(ctx, jarName, startIdx+idx,
nil, shardSrcJars, flags, extraJarDeps)
jars = append(jars, classes)
}
}
} else {
classes := j.compileJavaClasses(ctx, jarName, -1, uniqueJavaFiles, srcJars, flags, extraJarDeps)