Skip to content

Conversation

@GaryQian
Copy link
Contributor

@GaryQian GaryQian commented Aug 8, 2022

In discussion for #84868, We are seeing differences when running flutter build depending on if the contents of android/.gradle directory is populated or not. This is because gradle will download dependencies and generate the .gradle file on first run of the app.

This PR splits the inital compile time into initial and full, where initial implies building from a fully untouched never-before-compiled project, while full implies building after just running flutter clean.

This change adds about ~30s of build time to the hello_world_android__compile test task

@flutter-dashboard flutter-dashboard bot added the c: contributor-productivity Team-specific productivity, code health, technical debt. label Aug 8, 2022

final Map<String, dynamic> compileRelease = await _compileApp(reportPackageContentSizes: reportPackageContentSizes);
final Map<String, dynamic> compileDebug = await _compileDebug(
// "initial" compile required downloading and creating the `android/.gradle` directory while "full"
Copy link
Member

Choose a reason for hiding this comment

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

Factoring out the invocation that we know triggers a download into its own separate benchmark is a good start, but I think the end state we probably want to shoot for is factoring the download out into a step that the recipe can tag as an infra step rather than a test step.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A question is, do we want to track the gradle downloads as part of the build or do we consider it purely setup. The existing tests have the release_full_compile_millis shouldering the cost and is technically incorrect compared to the other benchmarks that benefit from not needing to download gradle.

Users will hit this when they try to initially build. Do we thing this extra cost is part of the build cost and thus belonging in the xxx_full_compile_millis bench or are we saying one-time initial costs are not a metric we want to track and thus want to separate it out into setup.

Copy link
Member

Choose a reason for hiding this comment

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

Hitting the network is not useful to include in a benchmark because we don't have any control over it. Said differently, what would we do if it suddenly became much slower to hit the network?

final Map<String, dynamic> compileDebug = await _compileDebug(
// "initial" compile required downloading and creating the `android/.gradle` directory while "full"
// compiles only run `flutter clean` between runs.gi
final Map<String, dynamic> compileInitialRelease = await _compileApp(deleteGradleCache: true);
Copy link
Member

Choose a reason for hiding this comment

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

Is there any way that the initial run can be taken only as far as needed to populate the cache?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe that only the build command triggers the gradle steps that populates the .gradle directory. We could make a flag or command to just populate things like this, but it would likely not be of much use outside of our tests.

@GaryQian GaryQian added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 29, 2022
@auto-submit auto-submit bot merged commit 3437fd9 into flutter:master Aug 29, 2022
jmagman added a commit that referenced this pull request Aug 30, 2022
jmagman added a commit that referenced this pull request Aug 30, 2022
@jmagman
Copy link
Member

jmagman commented Aug 30, 2022

This was reverted: #110550

Comment on lines +1486 to +1487
final Directory gradleCacheDir = Directory('$testDirectory/android/.gradle');
gradleCacheDir.deleteSync(recursive: true);
Copy link
Member

Choose a reason for hiding this comment

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

You can use rmTree when you reland this.

void rm(FileSystemEntity entity, { bool recursive = false}) {
if (entity.existsSync()) {
// This should not be necessary, but it turns out that
// on Windows it's common for deletions to fail due to
// bogus (we think) "access denied" errors.
try {
entity.deleteSync(recursive: recursive);
} on FileSystemException catch (error) {
print('Failed to delete ${entity.path}: $error');
}
}
}
/// Remove recursively.
void rmTree(FileSystemEntity entity) {
rm(entity, recursive: true);
}

engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 30, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Aug 30, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 30, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 1, 2022
GaryQian added a commit to GaryQian/flutter that referenced this pull request Sep 14, 2022
auto-submit bot pushed a commit that referenced this pull request Sep 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App c: contributor-productivity Team-specific productivity, code health, technical debt.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants