When an isolate dies it has to close all it's open ports. Right now this
is done by walking all ports in the system.
=> O(#num-isolates x #num-ports) complexity
Instead we let each isolate remember it's own open ports: When the
isolate dies we iterate over those ports that particular isolate has
open and close them.
=> O(#num-isolates + #num-ports) complexity
On a many-isolate test of the form:
foo(int n) {
if (n == 1) return 1;
return foo(n-1) + 1;
}
for `foo(50k)` this reduces the runtime from 90 seconds to 30 seconds.
Issue https://github.com/dart-lang/sdk/issues/36097
Change-Id: I3ac68c5334a1d5e8cac47e89e15cbb50c26b65ac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/144261
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
This CL extracts the hashset implementation from PortMap into
it's own (template) class into port_set.h:PortSet.
This splits the functionality (a nice cleanup in itself) and will
make it re-usable (via template) for a follow-up CL which makes
each message handler aware of it's own open ports.
Issue https://github.com/dart-lang/sdk/issues/36097
Change-Id: I4a56c997414672a4efc9330077110ac5f54d03d0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/144260
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>