Skip to content

Isolate.exit()s synchronous message validation happens in NoSafepointScope which harms responsiveness #49050

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

Closed
mkustermann opened this issue May 18, 2022 · 4 comments
Assignees
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. library-isolate

Comments

@mkustermann
Copy link
Member

The message validation code for Isolate.exit() runs synchronously in NoSafepointScope, see runtime/lib/isolate.cc:


static ObjectPtr ValidateMessageObject(Zone* zone,
                                       Isolate* isolate,
                                       const Object& obj) {
  ...
  {
    NoSafepointScope no_safepoint;
    ...
    while (!working_set.is_empty() && !error_found) {
      ...
    }
}

This is not a problem if no other threads want to safepoint, but if e.g. a UI isolate allocates widgets and will want to GC, it may have to wait for a long time (depending on how large the Isolate.exit()ed message is).

See a reproduction in isolate_exit_pause_time_issue.dart, which results in:

.Min(RunTimeRaw): 0.001 ms.
.Avg(RunTimeRaw): 388.26340250000004 ms.
.Percentile50(RunTimeRaw): 53.022 ms.
.Percentile90(RunTimeRaw): 1335.022 ms.
.Percentile95(RunTimeRaw): 1535.022 ms.
.Percentile99(RunTimeRaw): 1695.022 ms.
.Max(RunTimeRaw): 1734.022 ms.

/cc @aam Could you look into this?

@mkustermann mkustermann added area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. library-isolate labels May 18, 2022
@mkustermann
Copy link
Member Author

/cc @mit-mit

@aam aam self-assigned this May 18, 2022
@aam
Copy link
Contributor

aam commented May 18, 2022

/cc @aam Could you look into this?

Sure, thank you for putting the benchmark together. 10M objects in the exit message is quite a bit though! :-)

@mkustermann
Copy link
Member Author

Sure, thank you for putting the benchmark together. 10M objects in the exit message is quite a bit though! :-)

Some users do run compute() where the function parses 100 MB files. See d-markey/squadron#7 (comment):

Once I got the overall parse time for a 100MB VCD file down below the 30 seconds mark, performance was less of a consideration if it was happening in the background. In my case, the UI would freeze in debug mode and be more responsive in release mode (I can't remember for sure now, but I think that was native... can't remember web'.

@mkustermann
Copy link
Member Author

Thanks for looking into it, @aam !

copybara-service bot pushed a commit that referenced this issue Jun 1, 2022
This measures latency induced by one isolate send-and-exiting on concurrently running isolates.

The benchmark report format mimics EventLoopLatency benchmark, in a way it reports "runtime" as a latency.

TEST=manual run of benchmarks

Bug: #49050
Change-Id: I20642fd75bd24870658d553b0775f62083544bdb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/246620
Reviewed-by: Martin Kustermann <[email protected]>
Commit-Queue: Alexander Aprelev <[email protected]>
copybara-service bot pushed a commit that referenced this issue Jun 7, 2022
A benchmark should be in a directory with the same name as
the benchmark main file.

Bug: #49050
Change-Id: I31c0a9f276d313ab43d61be8ac3833b77ae8ee47
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247387
Commit-Queue: Alexander Aprelev <[email protected]>
Reviewed-by: Alexander Aprelev <[email protected]>
Auto-Submit: William Hesse <[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. library-isolate
Projects
None yet
Development

No branches or pull requests

2 participants