Open mraleph opened 5 months ago
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.
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: