RESOLVED FIXED 92505
[DRT] Replace JavaScriptThreadingPthreads.cpp with JavaScriptThreading.cpp
https://bugs.webkit.org/show_bug.cgi?id=92505
Summary [DRT] Replace JavaScriptThreadingPthreads.cpp with JavaScriptThreading.cpp
Patrick R. Gansterer
Reported 2012-07-27 07:21:40 PDT
[DRT] Replace JavaScriptThreadingPthreads.cpp with JavaScriptThreading.cpp
Attachments
Patch (31.03 KB, patch)
2012-07-27 07:24 PDT, Patrick R. Gansterer
no flags
Patch (32.21 KB, patch)
2012-07-27 08:48 PDT, Patrick R. Gansterer
no flags
Patch (22.19 KB, patch)
2013-04-07 18:06 PDT, Patrick R. Gansterer
bfulgham: review+
commit-queue: commit-queue-
Rebased Patch (only for EWS) (25.97 KB, patch)
2013-05-09 11:17 PDT, Patrick R. Gansterer
paroga: commit-queue-
Rebased Patch (only for EWS) (26.00 KB, patch)
2013-05-09 11:20 PDT, Patrick R. Gansterer
paroga: commit-queue-
Patrick R. Gansterer
Comment 1 2012-07-27 07:24:47 PDT
WebKit Review Bot
Comment 2 2012-07-27 07:39:49 PDT
Attachment 154942 [details] did not pass style-queue: Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Tools/ChangeLog', u'Tools/DumpRenderTree/D..." exit_code: 1 Tools/DumpRenderTree/JavaScriptThreading.cpp:82: This { should be at the end of the previous line [whitespace/braces] [4] Total errors found: 1 in 3 files If any of these errors are false positives, please file a bug against check-webkit-style.
Build Bot
Comment 3 2012-07-27 08:30:25 PDT
Patrick R. Gansterer
Comment 4 2012-07-27 08:48:17 PDT
WebKit Review Bot
Comment 5 2012-07-27 09:02:01 PDT
Attachment 154963 [details] did not pass style-queue: Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Tools/ChangeLog', u'Tools/DumpRenderTree/D..." exit_code: 1 Tools/DumpRenderTree/JavaScriptThreading.cpp:82: This { should be at the end of the previous line [whitespace/braces] [4] Total errors found: 1 in 3 files If any of these errors are false positives, please file a bug against check-webkit-style.
Ryosuke Niwa
Comment 6 2012-07-27 15:35:59 PDT
Comment on attachment 154963 [details] Patch Could you use svn mv instead of deleting the old file & adding the new file? That way, your change will show up as a diff.
Patrick R. Gansterer
Comment 7 2013-04-07 18:06:43 PDT
Brent Fulgham
Comment 8 2013-05-08 22:57:59 PDT
Comment on attachment 196817 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=196817&action=review Thanks for working on this -- I'm so excited to almost see PThreads gone on Windows! Overall I think this looks good, but I have some concerns that these modifications will change behavior. Of course, perhaps the changes will be for the better -- but I can't tell based on this bug. Could you please add more documentation in the bug as to why you changed the flow of the program, and what (if any) changes in behavior should be expected? I don't see EWS results for this change, so I can't assess whether this is safe or not. For these reasons, I'm marking r- until we clear up some of these questions. > Tools/DumpRenderTree/JavaScriptThreading.cpp:99 > + if (javaScriptThreadsShouldTerminate) Why is this now protected by a mutex? Reading a boolean should be an atomic operation; did you find this was causing you problems? > Tools/DumpRenderTree/JavaScriptThreading.cpp:104 > + if (rand() % 5) Why the change from random() to rand()? Is this just to be compatible between Windows and others? > Tools/DumpRenderTree/JavaScriptThreading.cpp:107 > + MutexLocker locker(javaScriptThreadsMutex()); The logic of the following section seems to change the behavior of the original code. Previously the flow was: 1. Lock mutex. 2. Create a new thread 3. Place it in the detached state (this could have perhaps been done by using pthread_attr_setdetachstate to setup flags for the pthread_create call. 4. Thread is added to the queue. 5. Unlock mutex. I like the use of the mutex object to control lifetime, but the logic now seems to be: 1. Lock mutex. 2. Get current running thread, and mark it as detached (presumable it was in a 'join' state before?) 3. Remove the current thread from the queue. 4. Create a new thread and add it to the thread queue. 5. (automatically Unlock mutex). Why the change? Am I misunderstanding your intent with this change? > Tools/DumpRenderTree/JavaScriptThreading.cpp:-109 > - javaScriptThreads()->remove(pthread_self()); Oh, I see. The remove was happening here. Still, why create the thread in a non-detached state? I think this could have an impact on the way the tests behave. > Tools/DumpRenderTree/JavaScriptThreading.cpp:128 > + javaScriptThreads().add(createThread(&runJavaScriptThread, 0, 0)); These threads are not in a detached state. If they terminate early, I don't think they get cleaned up properly. > Tools/DumpRenderTree/JavaScriptThreading.cpp:135 > + javaScriptThreadsShouldTerminate = true; Huh -- I see that we *were* locking to update the boolean here. Maybe this wasn't necessary?
Patrick R. Gansterer
Comment 9 2013-05-09 07:30:28 PDT
Comment on attachment 196817 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=196817&action=review >> Tools/DumpRenderTree/JavaScriptThreading.cpp:99 >> + if (javaScriptThreadsShouldTerminate) > > Why is this now protected by a mutex? Reading a boolean should be an atomic operation; did you find this was causing you problems? see other comment >> Tools/DumpRenderTree/JavaScriptThreading.cpp:104 >> + if (rand() % 5) > > Why the change from random() to rand()? Is this just to be compatible between Windows and others? yup, but I can keep random() in a first step if you like >> Tools/DumpRenderTree/JavaScriptThreading.cpp:107 >> + MutexLocker locker(javaScriptThreadsMutex()); > > The logic of the following section seems to change the behavior of the original code. Previously the flow was: > 1. Lock mutex. > 2. Create a new thread > 3. Place it in the detached state (this could have perhaps been done by using pthread_attr_setdetachstate to setup flags for the pthread_create call. > 4. Thread is added to the queue. > 5. Unlock mutex. > > I like the use of the mutex object to control lifetime, but the logic now seems to be: > 1. Lock mutex. > 2. Get current running thread, and mark it as detached (presumable it was in a 'join' state before?) > 3. Remove the current thread from the queue. > 4. Create a new thread and add it to the thread queue. > 5. (automatically Unlock mutex). > > Why the change? Am I misunderstanding your intent with this change? I merged the implementation with http://trac.webkit.org/browser/trunk/Tools/DumpRenderTree/win/DumpRenderTree.cpp?rev=149716#L1127, since I find it easier to understand and implement with the WTF threading API. It might have a different timing, but should fulfill all requirements, for which this code was introduced. >> Tools/DumpRenderTree/JavaScriptThreading.cpp:128 >> + javaScriptThreads().add(createThread(&runJavaScriptThread, 0, 0)); > > These threads are not in a detached state. If they terminate early, I don't think they get cleaned up properly. But we call waitForThreadCompletion() for _all_ threads now, which should take care of cleanup. >> Tools/DumpRenderTree/JavaScriptThreading.cpp:135 >> + javaScriptThreadsShouldTerminate = true; > > Huh -- I see that we *were* locking to update the boolean here. Maybe this wasn't necessary? I think so too, but didn't want to change behavior.
Brent Fulgham
Comment 10 2013-05-09 08:53:18 PDT
Based on paroga's comments, I think this looks fine. I wish the EWS had processed this, but we'll just have to watch the builders and make sure nothing goes wrong.
Brent Fulgham
Comment 11 2013-05-09 08:53:59 PDT
Comment on attachment 196817 [details] Patch After discussing further, I think this change looks good. r=me.
WebKit Commit Bot
Comment 12 2013-05-09 09:02:46 PDT
Comment on attachment 196817 [details] Patch Rejecting attachment 196817 [details] from commit-queue. Failed to run "['/Volumes/Data/EWS/WebKit/Tools/Scripts/webkit-patch', '--status-host=webkit-queues.appspot.com', '--bot-id=webkit-cq-03', 'apply-attachment', '--no-update', '--non-interactive', 196817, '--port=mac']" exit_code: 2 cwd: /Volumes/Data/EWS/WebKit Last 500 characters of output: es). Hunk #7 succeeded at 961 (offset 4 lines). Hunk #8 succeeded at 983 (offset 4 lines). Hunk #9 succeeded at 995 (offset 4 lines). patching file Tools/DumpRenderTree/pthreads/JavaScriptThreadingPthreads.cpp rm 'Tools/DumpRenderTree/pthreads/JavaScriptThreadingPthreads.cpp' patching file Tools/ChangeLog Hunk #1 succeeded at 1 with fuzz 3. Failed to run "[u'/Volumes/Data/EWS/WebKit/Tools/Scripts/svn-apply', '--force', '--reviewer', u'Brent Fulgham']" exit_code: 1 cwd: /Volumes/Data/EWS/WebKit Full output: http://webkit-queues.appspot.com/results/431283
Brent Fulgham
Comment 13 2013-05-09 09:03:56 PDT
Bah! Patrick, can you rebase the patch and submit again? I'll r+ it before things drift again. :-)
Patrick R. Gansterer
Comment 14 2013-05-09 11:17:54 PDT
Created attachment 201254 [details] Rebased Patch (only for EWS) I'll rebased the patch to check it via the EWS, but I'll land it manually via svn to keep track of the rename in the version history.
Patrick R. Gansterer
Comment 15 2013-05-09 11:20:03 PDT
Created attachment 201256 [details] Rebased Patch (only for EWS)
WebKit Commit Bot
Comment 16 2013-05-09 11:21:11 PDT
Attachment 201256 [details] did not pass style-queue: Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Tools/ChangeLog', u'Tools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj', u'Tools/DumpRenderTree/JavaScriptThreading.cpp', u'Tools/DumpRenderTree/pthreads/JavaScriptThreadingPthreads.cpp']" exit_code: 1 Tools/DumpRenderTree/JavaScriptThreading.cpp:31: Weird number of spaces at line-start. Are you using a 4-space indent? [whitespace/indent] [3] Tools/DumpRenderTree/JavaScriptThreading.cpp:82: This { should be at the end of the previous line [whitespace/braces] [4] Total errors found: 2 in 3 files If any of these errors are false positives, please file a bug against check-webkit-style.
Patrick R. Gansterer
Comment 17 2013-05-09 14:41:08 PDT
Note You need to log in before you can comment on or make changes to this bug.