Skip to content
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

Reduce the concurrency to avoid Dart VM lock up #2003

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions lib/src/embedded/isolate_dispatcher.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// https://opensource.org/licenses/MIT.

import 'dart:async';
import 'dart:ffi';
import 'dart:io';
import 'dart:isolate';
import 'dart:typed_data';
Expand Down Expand Up @@ -51,9 +52,12 @@ class IsolateDispatcher {
/// A pool controlling how many isolates (and thus concurrent compilations)
/// may be live at once.
///
/// More than 15 concurrent `waitFor()` calls seems to deadlock the Dart VM,
/// even across isolates. See sass/dart-sass#1959.
final _isolatePool = Pool(15);
/// The default MaxMutatorThreadCount is 4 on 32-bit system, and 8 on 64-bit system.
/// Having number of isolates going above it may lock up the dart vm.
/// Main isolate is also in the same isolate group so we should substract 1.
/// See https://github.com/dart-lang/sdk/blob/3.0.3/runtime/vm/globals.h#L63
/// See https://github.com/dart-lang/sdk/blob/3.0.3/runtime/vm/heap/scavenger.h#L222-L231
final _isolatePool = Pool(sizeOf<IntPtr>() <= 4 ? 3 : 7);

/// Whether the underlying channel has closed and the dispatcher is shutting
/// down.
Expand Down