Bug 163615 - DFG worklist should use AutomaticThread
Summary: DFG worklist should use AutomaticThread
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Filip Pizlo
URL:
Keywords:
Depends on: 163576
Blocks:
  Show dependency treegraph
 
Reported: 2016-10-18 13:20 PDT by Filip Pizlo
Modified: 2016-10-19 10:50 PDT (History)
9 users (show)

See Also:


Attachments
maybe this will work (18.42 KB, patch)
2016-10-18 13:47 PDT, Filip Pizlo
no flags Details | Formatted Diff | Diff
the patch (22.74 KB, patch)
2016-10-18 19:45 PDT, Filip Pizlo
mark.lam: review+
Details | Formatted Diff | Diff
patch for landing (22.97 KB, patch)
2016-10-18 22:21 PDT, Filip Pizlo
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Filip Pizlo 2016-10-18 13:20:40 PDT
Patch forthcoming.
Comment 1 Filip Pizlo 2016-10-18 13:47:42 PDT
Created attachment 291980 [details]
maybe this will work
Comment 2 Filip Pizlo 2016-10-18 19:45:36 PDT
Created attachment 292029 [details]
the patch
Comment 3 Mark Lam 2016-10-18 22:09:50 PDT
Comment on attachment 292029 [details]
the patch

View in context: https://bugs.webkit.org/attachment.cgi?id=292029&action=review

r=me

> Source/JavaScriptCore/dfg/DFGWorklist.cpp:78
> +                m_plan = nullptr;

I think it might be cleaner to use an RAII object to (1) RELEASE_ASSERT(m_plan) above, and (2) nullify m_plan on return.

> Source/WTF/wtf/AutomaticThread.h:150
> +    // It's sometimes useful to allocate resources while the thread is running, and do destroy them

typo: /do destroy/to destroy/
Comment 4 Filip Pizlo 2016-10-18 22:14:13 PDT
(In reply to comment #3)
> Comment on attachment 292029 [details]
> the patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=292029&action=review
> 
> r=me
> 
> > Source/JavaScriptCore/dfg/DFGWorklist.cpp:78
> > +                m_plan = nullptr;
> 
> I think it might be cleaner to use an RAII object to (1)
> RELEASE_ASSERT(m_plan) above, and (2) nullify m_plan on return.

I agree.  I will do that.

Also, I can use that scope to decrement m_numberOfActiveThreads.

> 
> > Source/WTF/wtf/AutomaticThread.h:150
> > +    // It's sometimes useful to allocate resources while the thread is running, and do destroy them
> 
> typo: /do destroy/to destroy/

Fixed.
Comment 5 Filip Pizlo 2016-10-18 22:16:03 PDT
Comment on attachment 292029 [details]
the patch

View in context: https://bugs.webkit.org/attachment.cgi?id=292029&action=review

>>> Source/JavaScriptCore/dfg/DFGWorklist.cpp:78
>>> +                m_plan = nullptr;
>> 
>> I think it might be cleaner to use an RAII object to (1) RELEASE_ASSERT(m_plan) above, and (2) nullify m_plan on return.
> 
> I agree.  I will do that.
> 
> Also, I can use that scope to decrement m_numberOfActiveThreads.

Hmmm, but that requires some tricks - since that count must be decremented when the lock is held.  I'll come up with something.
Comment 6 Filip Pizlo 2016-10-18 22:17:31 PDT
(In reply to comment #5)
> Comment on attachment 292029 [details]
> the patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=292029&action=review
> 
> >>> Source/JavaScriptCore/dfg/DFGWorklist.cpp:78
> >>> +                m_plan = nullptr;
> >> 
> >> I think it might be cleaner to use an RAII object to (1) RELEASE_ASSERT(m_plan) above, and (2) nullify m_plan on return.
> > 
> > I agree.  I will do that.
> > 
> > Also, I can use that scope to decrement m_numberOfActiveThreads.
> 
> Hmmm, but that requires some tricks - since that count must be decremented
> when the lock is held.  I'll come up with something.

Oh it's easy!  The m_numberOfActiveThreads count is just for debugging.  So, although we want to hold the lock when decrementing it, we can do it in a separate critical section from everything else.  This means that the scoped idiom still works.
Comment 7 Filip Pizlo 2016-10-18 22:21:54 PDT
Created attachment 292044 [details]
patch for landing
Comment 8 Filip Pizlo 2016-10-18 22:23:55 PDT
I'm going to build the full stack so that I can run JetStream locally.  I'm pretty sure that JetStream might thrash with the 1 second timeout.  My hope is that it won't matter because the cost of starting a thread is low enough that you can safely pay it once per second.
Comment 9 WebKit Commit Bot 2016-10-18 22:26:40 PDT
Attachment 292044 [details] did not pass style-queue:


ERROR: Source/JavaScriptCore/dfg/DFGWorklist.cpp:112:  Multi line control clauses should use braces.  [whitespace/braces] [4]
Total errors found: 1 in 8 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 10 Filip Pizlo 2016-10-19 10:48:51 PDT
(In reply to comment #8)
> I'm going to build the full stack so that I can run JetStream locally.  I'm
> pretty sure that JetStream might thrash with the 1 second timeout.  My hope
> is that it won't matter because the cost of starting a thread is low enough
> that you can safely pay it once per second.

My experiments show that this patch might be a small JetStream progression.
Comment 11 Filip Pizlo 2016-10-19 10:50:52 PDT
Landed in https://trac.webkit.org/changeset/207545