Isolate.exit uses Isolate::KillIfExists which is O(num_isolates) operation #50789
Labels
area-vm
Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.
P2
A bug or feature request we're likely to work on
triaged
Issue has been triaged by sub team
type-performance
Issue relates to performance or code size
I was a bit curious why this code from Reddit is so slow. Turns out that
Isolate.exit
callsIsolate::KillIfExists
which visits all the isolates and does the following:This seems wrong - it is an extremely expensive operation when number of isolates is large: it takes lock when visiting each isolate, so there is potential for high contention when many isolates are calling
Isolate.exit
at the same time.I don't think
Isolate::KillIfExists
should be used when we already own the isolate like withIsolate.exit
.KillIfExists
is for killing other isolates in a race free manner.The text was updated successfully, but these errors were encountered: