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

☂️ Explore shared memory multithreading #55991

Open
mraleph opened this issue Jun 12, 2024 · 1 comment
Open

☂️ Explore shared memory multithreading #55991

mraleph opened this issue Jun 12, 2024 · 1 comment
Assignees
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. type-enhancement A request for a change that isn't a bug

Comments

@mraleph
Copy link
Member

mraleph commented Jun 12, 2024

This is an umbrella issue for exploring possible relaxation of Dart's isolate model and introducing some variation of shared memory multithreading into Dart.

Related:

@mraleph mraleph added the area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. label Jun 12, 2024
@a-siva a-siva added the type-enhancement A request for a change that isn't a bug label Jun 12, 2024
copybara-service bot pushed a commit that referenced this issue Jun 14, 2024
Decorating a field with 'vm:shared' pragma makes values in this field accessible to all isolates in an isolate group.

Introduce `channel` to the `Version` class so that the pragma can only be enabled on main and dev channels.

TEST=shared_test, shared_fail_without_flag_test
BUG=#55991

Change-Id: I843c9f0d2ffc9f2ced7ddc4006bb6f9ca4e2ddf4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370064
Reviewed-by: Slava Egorov <[email protected]>
Commit-Queue: Alexander Aprelev <[email protected]>
copybara-service bot pushed a commit that referenced this issue Jun 20, 2024
BUG=#56016
BUG=#55991
TEST=shared_test in appjit

Change-Id: I94ee12355cea95ca1c2698ee77e7ceffe81e27e1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/371944
Commit-Queue: Alexander Aprelev <[email protected]>
Reviewed-by: Martin Kustermann <[email protected]>
@mraleph
Copy link
Member Author

mraleph commented Jul 10, 2024

One open question about shared everything multithreading is around the cost of barriers required to maintain memory model and type safety. Consider the following code:

class X {
  List v;
  X() : v = [];
}

@pragma('vm:shared')
X x = X();

thread1() {
  x = X();
}

thread2() {
  x.v.length;
}

We don't want read of x.v to return null (or worse - garbage), because writes of x and x.v are reordered by hardware with weak memory model.

We should experiment with adding barrier to measure the synchronization cost. We can start by adding a barrier to GenerateAllocateObjectHelper and doing a Golem run.

copybara-service bot pushed a commit that referenced this issue Jul 10, 2024
This brings Mutex and ConditionVariable classes to guard access to shared variables.

TEST=shared_test, shared_primitives_test
BUG=#55991
CoreLibraryReviewExempt: dart:concurrent library is experimental, restricted to main/dev channels, vm-only at this point.
Change-Id: I64ca7a0434cbe0079976133ccbf9de2dd4c0d7b1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/372181
Commit-Queue: Alexander Aprelev <[email protected]>
Reviewed-by: Slava Egorov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

3 participants