-
Notifications
You must be signed in to change notification settings - Fork 98
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
Send batch requests when scheduling new commit builds #1999
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import 'dart:math'; | ||
import 'dart:typed_data'; | ||
|
||
import 'package:cocoon_service/src/service/build_status_provider.dart'; | ||
|
@@ -154,11 +155,24 @@ class Scheduler { | |
log.severe('Failed to add commit ${commit.sha!}: $error'); | ||
} | ||
|
||
await luciBuildService.schedulePostsubmitBuilds(commit: commit, toBeScheduled: toBeScheduled); | ||
|
||
await _batchScheduleBuilds(commit, toBeScheduled); | ||
await _uploadToBigQuery(commit); | ||
} | ||
|
||
/// Schedule all builds in batch requests instead of a single request. | ||
/// | ||
/// Each batch request contains `kBatchSize` builds to be scheduled. | ||
Future<void> _batchScheduleBuilds(Commit commit, List<Tuple<Target, Task, int>> toBeScheduled) async { | ||
final List<Future> futures = <Future>[]; | ||
for (int i = 0; i < toBeScheduled.length; i += config.batchSize) { | ||
futures.add(luciBuildService.schedulePostsubmitBuilds( | ||
commit: commit, | ||
toBeScheduled: toBeScheduled.sublist(i, min(i + config.batchSize, toBeScheduled.length)), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is sublist upper bound index non-inclusive? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's correct. |
||
)); | ||
} | ||
await Future.wait<void>(futures); | ||
} | ||
|
||
/// Return subset of [commits] not stored in Datastore. | ||
Future<List<Commit>> _getMissingCommits(List<Commit> commits) async { | ||
final List<Commit> newCommits = <Commit>[]; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,6 +56,7 @@ class FakeConfig implements Config { | |
this.supportedBranchesValue, | ||
this.luciBuildersValue, | ||
this.supportedReposValue, | ||
this.batchSizeValue, | ||
FakeDatastoreDB? dbValue, | ||
}) : dbValue = dbValue ?? FakeDatastoreDB(); | ||
|
||
|
@@ -69,6 +70,7 @@ class FakeConfig implements Config { | |
ServiceAccountInfo? deviceLabServiceAccountValue; | ||
int? maxTaskRetriesValue; | ||
int? maxLuciTaskRetriesValue; | ||
int? batchSizeValue; | ||
FakeKeyHelper? keyHelperValue; | ||
String? oauthClientIdValue; | ||
String? githubOAuthTokenValue; | ||
|
@@ -132,6 +134,9 @@ class FakeConfig implements Config { | |
@override | ||
int get schedulingShardSize => 5; | ||
|
||
@override | ||
int get batchSize => batchSizeValue ?? 5; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Making this const in config.dart would prevent need to add this stub in the test There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I need to have customized |
||
|
||
@override | ||
int get maxLuciTaskRetries => maxLuciTaskRetriesValue!; | ||
|
||
|
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.
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