Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(401)

Issue 9924015: Use the ThreadPool for all isolates and native ports. Previously, (Closed)

Created:
8 years, 8 months ago by turnidge
Modified:
8 years, 8 months ago
Reviewers:
siva, Ivan Posva
CC:
reviews_dartlang.org, vm-dev_dartlang.org
Visibility:
Public.

Description

Use the ThreadPool for all isolates and native ports. Previously, each isolate or native port had a dedicated thread. Refactored the MessageHandler api... - Added a Run function to allow a MessageHandler to run on a ThreadPool. These functions take a start and end callback to allow for isolate initialization and shutdown. - Made the queue private to the MessageHandler and moved all message processing code inside the MessageHandler (got rid of all of the different flavors of RunLoop). This helps remove some code duplication and hides the details of how messages are handled. - Moved all locking and notification out of MessageQueue and moved it up to MessageHandler. Moved OOB support out of MessageQueue and up to MessageHandler. These changes make the MessageQueue much simpler. - Refactored native port and isolate MessageHandlers to share more code. - Improved --trace_isolates output. - Added tests for MessageHandler. Refactored lib/isolate code... - Use the new MessageHandler::Run api. - Got rid of the LongJump stuff in RunIsolate. No longer needed. - Use the new StartIsolateScope/SwitchIsolateScope to make the code less verbose and less error-prone. - Store top-level isolate errors in the sticky_error. Added StartIsolateScope/SwitchIsolateScope classes. Committed: https://code.google.com/p/dart/source/detail?r=6762

Patch Set 1 #

Total comments: 7

Patch Set 2 : #

Total comments: 50

Patch Set 3 : #

Patch Set 4 : #

Patch Set 5 : #

Patch Set 6 : #

Total comments: 16

Patch Set 7 : #

Patch Set 8 : #

Patch Set 9 : #

Unified diffs Side-by-side diffs Delta from patch set Stats (+860 lines, -974 lines) Patch
M runtime/lib/isolate.cc View 1 2 3 4 5 6 7 8 12 chunks +63 lines, -78 lines 0 comments Download
M runtime/vm/code_generator.cc View 1 2 3 4 5 6 3 chunks +2 lines, -36 lines 0 comments Download
M runtime/vm/dart.h View 1 2 3 4 5 6 3 chunks +3 lines, -0 lines 0 comments Download
M runtime/vm/dart.cc View 1 2 3 4 5 6 3 chunks +5 lines, -0 lines 0 comments Download
M runtime/vm/dart_api_impl.cc View 1 2 3 4 5 6 4 chunks +41 lines, -53 lines 0 comments Download
M runtime/vm/isolate.h View 1 2 3 4 5 6 7 8 5 chunks +68 lines, -5 lines 0 comments Download
M runtime/vm/isolate.cc View 1 2 3 4 5 6 5 chunks +56 lines, -63 lines 0 comments Download
M runtime/vm/message.h View 1 2 3 4 5 6 2 chunks +7 lines, -73 lines 0 comments Download
M runtime/vm/message.cc View 1 2 3 4 5 6 1 chunk +43 lines, -150 lines 0 comments Download
A + runtime/vm/message_handler.h View 1 2 3 4 2 chunks +84 lines, -111 lines 0 comments Download
A + runtime/vm/message_handler.cc View 1 2 3 4 5 6 3 chunks +176 lines, -103 lines 0 comments Download
A runtime/vm/message_handler_test.cc View 1 2 3 4 5 6 1 chunk +268 lines, -0 lines 0 comments Download
M runtime/vm/message_test.cc View 1 2 3 4 5 6 4 chunks +6 lines, -148 lines 0 comments Download
M runtime/vm/native_message_handler.h View 1 2 3 4 5 6 3 chunks +3 lines, -10 lines 0 comments Download
M runtime/vm/native_message_handler.cc View 1 2 3 4 5 6 1 chunk +16 lines, -39 lines 0 comments Download
M runtime/vm/port.cc View 1 2 3 4 5 6 1 chunk +1 line, -1 line 0 comments Download
M runtime/vm/port_test.cc View 1 2 3 4 5 6 8 chunks +11 lines, -103 lines 0 comments Download
M runtime/vm/thread_pool.cc View 1 2 3 4 5 6 1 chunk +4 lines, -1 line 0 comments Download
M runtime/vm/vm_sources.gypi View 1 2 3 4 5 6 1 chunk +3 lines, -0 lines 0 comments Download

Messages

Total messages: 8 (0 generated)
turnidge
8 years, 8 months ago (2012-03-29 18:06:02 UTC) #1
Ivan Posva
First round of comments. -Ivan https://chromiumcodereview.appspot.com/9924015/diff/1/runtime/vm/isolate.h File runtime/vm/isolate.h (right): https://chromiumcodereview.appspot.com/9924015/diff/1/runtime/vm/isolate.h#newcode298 runtime/vm/isolate.h:298: if (new_isolate) { if ...
8 years, 8 months ago (2012-04-08 22:58:27 UTC) #2
turnidge
Ready for another look. https://chromiumcodereview.appspot.com/9924015/diff/1/runtime/vm/isolate.h File runtime/vm/isolate.h (right): https://chromiumcodereview.appspot.com/9924015/diff/1/runtime/vm/isolate.h#newcode298 runtime/vm/isolate.h:298: if (new_isolate) { On 2012/04/08 ...
8 years, 8 months ago (2012-04-11 19:37:16 UTC) #3
siva
https://chromiumcodereview.appspot.com/9924015/diff/8001/runtime/lib/isolate.cc File runtime/lib/isolate.cc (right): https://chromiumcodereview.appspot.com/9924015/diff/8001/runtime/lib/isolate.cc#newcode136 runtime/lib/isolate.cc:136: // For now, we only support a non-parameterized or ...
8 years, 8 months ago (2012-04-14 00:29:53 UTC) #4
turnidge
Hi Siva, Thanks for your comments... you found some serious problems. Ready for another look. ...
8 years, 8 months ago (2012-04-17 23:46:54 UTC) #5
turnidge
https://chromiumcodereview.appspot.com/9924015/diff/8001/runtime/vm/dart_api_impl.cc File runtime/vm/dart_api_impl.cc (right): https://chromiumcodereview.appspot.com/9924015/diff/8001/runtime/vm/dart_api_impl.cc#newcode775 runtime/vm/dart_api_impl.cc:775: SetIsolateScope set_scope(NULL); On 2012/04/17 23:46:55, turnidge wrote: > On ...
8 years, 8 months ago (2012-04-17 23:49:20 UTC) #6
siva
lgtm https://chromiumcodereview.appspot.com/9924015/diff/8001/runtime/lib/isolate.cc File runtime/lib/isolate.cc (right): https://chromiumcodereview.appspot.com/9924015/diff/8001/runtime/lib/isolate.cc#newcode523 runtime/lib/isolate.cc:523: if (result != 0) { FATAL is fine ...
8 years, 8 months ago (2012-04-18 22:04:59 UTC) #7
turnidge
8 years, 8 months ago (2012-04-19 19:46:55 UTC) #8
https://chromiumcodereview.appspot.com/9924015/diff/18007/runtime/lib/isolate.cc
File runtime/lib/isolate.cc (right):

https://chromiumcodereview.appspot.com/9924015/diff/18007/runtime/lib/isolate...
runtime/lib/isolate.cc:117: intptr_t port_id = data->port_id_;
On 2012/04/18 22:05:00, asiva wrote:
> When is data deleted in the new scheme?

That was missing.  Added.

https://chromiumcodereview.appspot.com/9924015/diff/18007/runtime/vm/dart_api...
File runtime/vm/dart_api_impl.cc (right):

https://chromiumcodereview.appspot.com/9924015/diff/18007/runtime/vm/dart_api...
runtime/vm/dart_api_impl.cc:778: RunLoopData* data =
reinterpret_cast<RunLoopData*>(param);
On 2012/04/18 22:05:00, asiva wrote:
> ASSERT(data->monitor != NULL);

Done.

https://chromiumcodereview.appspot.com/9924015/diff/18007/runtime/vm/isolate.h
File runtime/vm/isolate.h (right):

https://chromiumcodereview.appspot.com/9924015/diff/18007/runtime/vm/isolate....
runtime/vm/isolate.h:229: // StartIsolateScope.
On 2012/04/18 22:05:00, asiva wrote:
> It is not necessarily a new isolate right, anytime we execute code in an
isolate
> (i.e handle a message) we call StartIsolateScope.

Done.

https://chromiumcodereview.appspot.com/9924015/diff/18007/runtime/vm/isolate....
runtime/vm/isolate.h:241: ~StartIsolateScope() {
On 2012/04/18 22:05:00, asiva wrote:
> Should we set the stack limit of the isolate we are about to switch out of to
> some value like 0. It will ensure that we don't ever run code without going
> through the constructor above.

Done.  Had to rework ShutdownIsolate a bit in lib/isolate.cc to avoid deleting
the isolate during a StartIsolateScope.

https://chromiumcodereview.appspot.com/9924015/diff/18007/runtime/vm/isolate....
runtime/vm/isolate.h:266: Isolate::SetCurrent(saved_isolate_);
On 2012/04/18 22:05:00, asiva wrote:
> Shouldn't we be restoring the stack limit of new_isolate (isolate we are going
> to switch out of) to what it was before you set it to 0.

Done.

https://chromiumcodereview.appspot.com/9924015/diff/18007/runtime/vm/message_...
File runtime/vm/message_handler.cc (right):

https://chromiumcodereview.appspot.com/9924015/diff/18007/runtime/vm/message_...
runtime/vm/message_handler.cc:16: : handler_(handler) {
On 2012/04/18 22:05:00, asiva wrote:
> ASSERT(handler != NULL);

Done.

https://chromiumcodereview.appspot.com/9924015/diff/18007/runtime/vm/message_...
runtime/vm/message_handler.cc:173: ASSERT(pool_ == NULL);
On 2012/04/18 22:05:00, asiva wrote:
> The assert should be after grabbing the lock?

Done.

https://chromiumcodereview.appspot.com/9924015/diff/18007/runtime/vm/message_...
File runtime/vm/message_handler_test.cc (right):

https://chromiumcodereview.appspot.com/9924015/diff/18007/runtime/vm/message_...
runtime/vm/message_handler_test.cc:256: }
On 2012/04/18 22:05:00, asiva wrote:
> if there is a bug this test will hang forever, do you think it would make
sense
> to quite after a certain number of retries ?

I've added code to limit the test to about 20 seconds.

Powered by Google App Engine
This is Rietveld 408576698