Skip to content

Commit 37b7db0

Browse files
rmacnak-googleCommit Queue
authored andcommitted
[io] Limit the IOService to 1 thread when running with --deterministic.
TEST=locally build the SDK twice without RBE Bug: #56884 Change-Id: I59110f92c737fb1137e12114f6bcaacfd6283347 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/391463 Reviewed-by: Brian Quinlan <[email protected]> Commit-Queue: Ryan Macnak <[email protected]>
1 parent 9a67968 commit 37b7db0

File tree

5 files changed

+25
-2
lines changed

5 files changed

+25
-2
lines changed

runtime/bin/io_service.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,11 @@ void IOServiceCallback(Dart_Port dest_port_id, Dart_CObject* message) {
5454
Dart_PostCObject(reply_port_id, result.AsApiCObject());
5555
}
5656

57+
intptr_t IOService::max_concurrency_ = 32;
58+
5759
Dart_Port IOService::GetServicePort() {
5860
return Dart_NewConcurrentNativePort("IOService", IOServiceCallback,
59-
/*max_concurrency=*/32);
61+
max_concurrency_);
6062
}
6163

6264
void FUNCTION_NAME(IOService_NewServicePort)(Dart_NativeArguments args) {

runtime/bin/io_service.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,12 @@ class IOService {
7070

7171
static Dart_Port GetServicePort();
7272

73+
static intptr_t max_concurrency() { return max_concurrency_; }
74+
static void set_max_concurrency(intptr_t value) { max_concurrency_ = value; }
75+
7376
private:
77+
static intptr_t max_concurrency_;
78+
7479
DISALLOW_ALLOCATION();
7580
DISALLOW_IMPLICIT_CONSTRUCTORS(IOService);
7681
};

runtime/bin/io_service_no_ssl.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,11 @@ void IOServiceCallback(Dart_Port dest_port_id, Dart_CObject* message) {
5252
Dart_PostCObject(reply_port_id, result.AsApiCObject());
5353
}
5454

55+
intptr_t IOService::max_concurrency_ = 32;
56+
5557
Dart_Port IOService::GetServicePort() {
5658
return Dart_NewConcurrentNativePort("IOService", IOServiceCallback,
57-
/*max_concurrency=*/32);
59+
max_concurrency_);
5860
}
5961

6062
void FUNCTION_NAME(IOService_NewServicePort)(Dart_NativeArguments args) {

runtime/bin/io_service_no_ssl.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,12 @@ class IOService {
7171

7272
static Dart_Port GetServicePort();
7373

74+
static intptr_t max_concurrency() { return max_concurrency_; }
75+
static void set_max_concurrency(intptr_t value) { max_concurrency_ = value; }
76+
7477
private:
78+
static intptr_t max_concurrency_;
79+
7580
DISALLOW_ALLOCATION();
7681
DISALLOW_IMPLICIT_CONSTRUCTORS(IOService);
7782
};

runtime/bin/main_options.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111
#include "bin/dartdev_isolate.h"
1212
#include "bin/error_exit.h"
1313
#include "bin/file_system_watcher.h"
14+
#if defined(DART_IO_SECURE_SOCKET_DISABLED)
15+
#include "bin/io_service_no_ssl.h"
16+
#else // defined(DART_IO_SECURE_SOCKET_DISABLED)
17+
#include "bin/io_service.h"
18+
#endif // defined(DART_IO_SECURE_SOCKET_DISABLED)
1419
#include "bin/options.h"
1520
#include "bin/platform.h"
1621
#include "bin/utils.h"
@@ -606,6 +611,10 @@ bool Options::ParseArguments(int argc,
606611
FileSystemWatcher::set_delayed_filewatch_callback(
607612
Options::delayed_filewatch_callback());
608613

614+
if (Options::deterministic()) {
615+
IOService::set_max_concurrency(1);
616+
}
617+
609618
// The arguments to the VM are at positions 1 through i-1 in argv.
610619
Platform::SetExecutableArguments(i, argv);
611620

0 commit comments

Comments
 (0)