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

Issue 371623002: [oilpan]: Make thread shutdown more robust. (Closed)

Created:
6 years, 5 months ago by wibling-chromium
Modified:
6 years, 5 months ago
CC:
blink-reviews, kouhei+heap_chromium.org, Mads Ager (chromium)
Project:
blink
Visibility:
Public.

Description

[oilpan]: Make thread shutdown more robust. Change the way we shutdown threads to ensure we are not leaving dangling pointers from other thread heaps into pages being freed at shutdown. Thread shutdown algorithm: 1. Mark all pages belonging to the thread as being in the shutdown phase. This helps us to avoid trace pages not belonging to the thread being shut down. 2. Trace the thread’s objects using only the thread local persistents as roots. 3. Sweep the thread’s pages, any empty pages are put in the orphaned page pool since there is a risk a conservatively found (dead) object in another thread could trace this thread’s pages in the following global GC. The page is moved from the orphaned page pool to the memory pool after a global GC marking at which point we know it cannot be reached. 4. Repeat step 2 and 3 until the number of thread local persistents reaches zero or does not decrease. 5. Do a final sweep with no tracing to finalize the remaining objects in the thread’s heaps. 6. When destructing the thread state move any remaining pages or large objects to the orphaned page pool. To make the above assumption of the next global GC marking being sufficient to know that a page cannot be reached we need to guarantee that an object cannot be revived. Reviving an object can happen if a thread doesn’t get to sweep before the next GC marking phase. In that case the new marking could conservatively find an object on the heap that were not found in the first marking and hence revive an object that were dead. This newly revived object could contain pointers to another object on a thread that had swept its pages and we would then try to trace potential garbage or even a newly allocated object on the swept object’s location. We have introduced a dead bit to avoid the above. This dead bit is set during the prepareForGC call if a thread didn’t get to sweep before the new GC. R=ager@chromium.org, erik.corry@gmail.com, haraken@chromium.org, oilpan-reviews@chromium.org, tkent@chromium.org, vegorov@chromium.org, zerny@chromium.org BUG=375671 Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=178044

Patch Set 1 #

Patch Set 2 : #

Total comments: 28

Patch Set 3 : review feedback #

Total comments: 116

Patch Set 4 : review feedback #

Total comments: 43

Patch Set 5 : #

Total comments: 15

Patch Set 6 : more review feedback #

Patch Set 7 : rebase and merge #

Patch Set 8 : #

Total comments: 20

Patch Set 9 : #

Patch Set 10 : fix heapTests compile on android #

Patch Set 11 : #

Unified diffs Side-by-side diffs Delta from patch set Stats (+978 lines, -320 lines) Patch
M Source/platform/heap/Handle.h View 1 2 3 4 2 chunks +11 lines, -0 lines 0 comments Download
M Source/platform/heap/Heap.h View 1 2 3 4 5 6 7 8 23 chunks +118 lines, -102 lines 0 comments Download
M Source/platform/heap/Heap.cpp View 1 2 3 4 5 6 7 8 27 chunks +372 lines, -151 lines 0 comments Download
M Source/platform/heap/HeapTest.cpp View 1 2 3 4 5 6 7 8 9 10 7 chunks +284 lines, -3 lines 0 comments Download
M Source/platform/heap/ThreadState.h View 1 2 3 4 5 6 8 chunks +62 lines, -5 lines 0 comments Download
M Source/platform/heap/ThreadState.cpp View 1 2 3 4 5 6 7 8 10 chunks +110 lines, -48 lines 0 comments Download
M Source/platform/heap/Visitor.h View 1 2 3 4 1 chunk +12 lines, -2 lines 0 comments Download
M Source/platform/heap/Visitor.cpp View 1 2 3 4 1 chunk +9 lines, -9 lines 0 comments Download

Messages

Total messages: 34 (0 generated)
wibling-chromium
6 years, 5 months ago (2014-07-04 13:26:19 UTC) #1
wibling-chromium
PTAL. I have updated the description and fixed a null pointer issue.
6 years, 5 months ago (2014-07-07 08:55:54 UTC) #2
zerny-chromium
Mostly lgtm. I think the comments can be tightened a bit and updated to include ...
6 years, 5 months ago (2014-07-07 12:11:56 UTC) #3
wibling-chromium
Thanks for the review. I will update the diff ASAP. https://codereview.chromium.org/371623002/diff/20001/Source/platform/heap/Heap.cpp File Source/platform/heap/Heap.cpp (right): https://codereview.chromium.org/371623002/diff/20001/Source/platform/heap/Heap.cpp#newcode764 ...
6 years, 5 months ago (2014-07-07 13:50:07 UTC) #4
haraken
This is a nice change!! I haven't looked at Heap.{h,cpp}, which I'll take a look ...
6 years, 5 months ago (2014-07-07 16:13:47 UTC) #5
haraken
Added a couple of more comments. Great change anyway. https://codereview.chromium.org/371623002/diff/40001/Source/platform/heap/Heap.cpp File Source/platform/heap/Heap.cpp (left): https://codereview.chromium.org/371623002/diff/40001/Source/platform/heap/Heap.cpp#oldcode870 Source/platform/heap/Heap.cpp:870: ...
6 years, 5 months ago (2014-07-08 05:44:52 UTC) #6
zerny-chromium
https://codereview.chromium.org/371623002/diff/20001/Source/platform/heap/Heap.cpp File Source/platform/heap/Heap.cpp (right): https://codereview.chromium.org/371623002/diff/20001/Source/platform/heap/Heap.cpp#newcode1526 Source/platform/heap/Heap.cpp:1526: if (ThreadLocal ? (heapPage->orphaned() || !heapPage->shuttingDown()) : heapPage->orphaned()) { ...
6 years, 5 months ago (2014-07-08 08:11:03 UTC) #7
Mads Ager (chromium)
Thank you for working on this Gustav. This change is fixing a bunch of real ...
6 years, 5 months ago (2014-07-08 08:24:57 UTC) #8
wibling-chromium
Thanks for all the reviews! I have replied inline below and will update the diff ...
6 years, 5 months ago (2014-07-08 13:39:48 UTC) #9
wibling-chromium
PTAL. The diff is updated with the review feedback. Notice I have also changed the ...
6 years, 5 months ago (2014-07-08 15:32:20 UTC) #10
haraken
(I'll take another close look at Heap.{h,cpp} shortly...) https://codereview.chromium.org/371623002/diff/40001/Source/platform/heap/HeapTest.cpp File Source/platform/heap/HeapTest.cpp (right): https://codereview.chromium.org/371623002/diff/40001/Source/platform/heap/HeapTest.cpp#newcode2 Source/platform/heap/HeapTest.cpp:2: * ...
6 years, 5 months ago (2014-07-09 05:17:49 UTC) #11
haraken
Mostly looks good! https://codereview.chromium.org/371623002/diff/60001/Source/platform/heap/Heap.cpp File Source/platform/heap/Heap.cpp (right): https://codereview.chromium.org/371623002/diff/60001/Source/platform/heap/Heap.cpp#newcode808 Source/platform/heap/Heap.cpp:808: MutexLocker locker(m_mutex[index]); Just to confirm: Doesn't ...
6 years, 5 months ago (2014-07-09 08:01:59 UTC) #12
Mads Ager (chromium)
Code looks good to me. I agree with Haraken that writing a couple of regression ...
6 years, 5 months ago (2014-07-09 09:31:40 UTC) #13
wibling-chromium
Thanks again for the thorough reviews. I will update a diff with the changes and ...
6 years, 5 months ago (2014-07-09 10:32:32 UTC) #14
wibling-chromium
FYI. I am looking into an issue with tracing of large collections with value object. ...
6 years, 5 months ago (2014-07-09 15:21:44 UTC) #15
haraken
I just want to understand, but is there any reason that makes it hard to ...
6 years, 5 months ago (2014-07-09 16:02:09 UTC) #16
Mads Ager (chromium)
One more comment. This is tricky to get right, but I do think we are ...
6 years, 5 months ago (2014-07-11 05:48:06 UTC) #17
wibling-chromium
On 2014/07/09 16:02:09, haraken wrote: > I just want to understand, but is there any ...
6 years, 5 months ago (2014-07-11 10:14:44 UTC) #18
wibling-chromium
On 2014/07/11 05:48:06, Mads Ager (chromium) wrote: > One more comment. This is tricky to ...
6 years, 5 months ago (2014-07-11 10:15:18 UTC) #19
wibling-chromium
PTAL. I have incorporated all of the feedback, added tests for PersistentHeapCollection with weakness, cross ...
6 years, 5 months ago (2014-07-11 10:21:08 UTC) #20
Mads Ager (chromium)
LGTM https://codereview.chromium.org/371623002/diff/80001/Source/platform/heap/Heap.cpp File Source/platform/heap/Heap.cpp (right): https://codereview.chromium.org/371623002/diff/80001/Source/platform/heap/Heap.cpp#newcode2008 Source/platform/heap/Heap.cpp:2008: // XXX: Add slow case check for not ...
6 years, 5 months ago (2014-07-11 10:59:34 UTC) #21
zerny-chromium
LGTM https://codereview.chromium.org/371623002/diff/80001/Source/platform/heap/Heap.cpp File Source/platform/heap/Heap.cpp (right): https://codereview.chromium.org/371623002/diff/80001/Source/platform/heap/Heap.cpp#newcode963 Source/platform/heap/Heap.cpp:963: // newly allocated page memory before this thread ...
6 years, 5 months ago (2014-07-11 11:24:42 UTC) #22
wibling-chromium
Thanks for the reviews. I have updated the diffs with the latest feedback. https://codereview.chromium.org/371623002/diff/80001/Source/platform/heap/Heap.cpp File ...
6 years, 5 months ago (2014-07-11 13:06:54 UTC) #23
haraken
LGTM! https://codereview.chromium.org/371623002/diff/60001/Source/platform/heap/Visitor.h File Source/platform/heap/Visitor.h (right): https://codereview.chromium.org/371623002/diff/60001/Source/platform/heap/Visitor.h#newcode604 Source/platform/heap/Visitor.h:604: if (heapPage->orphaned()) { On 2014/07/09 10:32:31, wibling-chromium wrote: ...
6 years, 5 months ago (2014-07-13 17:30:39 UTC) #24
wibling-chromium
Thanks for the reviews! I have updated the diff and will start the commit. https://codereview.chromium.org/371623002/diff/60001/Source/platform/heap/Visitor.h ...
6 years, 5 months ago (2014-07-14 08:06:11 UTC) #25
wibling-chromium
The CQ bit was checked by wibling@chromium.org
6 years, 5 months ago (2014-07-14 08:07:23 UTC) #26
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/wibling@chromium.org/371623002/160001
6 years, 5 months ago (2014-07-14 08:08:24 UTC) #27
wibling-chromium
The CQ bit was checked by wibling@chromium.org
6 years, 5 months ago (2014-07-14 08:29:38 UTC) #28
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/wibling@chromium.org/371623002/180001
6 years, 5 months ago (2014-07-14 08:29:58 UTC) #29
commit-bot: I haz the power
FYI, CQ is re-trying this CL (attempt #1). The failing builders are: linux_blink_dbg on tryserver.blink ...
6 years, 5 months ago (2014-07-14 09:20:29 UTC) #30
wibling-chromium
The CQ bit was checked by wibling@chromium.org
6 years, 5 months ago (2014-07-14 09:29:32 UTC) #31
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/wibling@chromium.org/371623002/200001
6 years, 5 months ago (2014-07-14 09:30:38 UTC) #32
commit-bot: I haz the power
FYI, CQ is re-trying this CL (attempt #1). The failing builders are: win_blink_rel on tryserver.blink ...
6 years, 5 months ago (2014-07-14 10:39:58 UTC) #33
commit-bot: I haz the power
6 years, 5 months ago (2014-07-14 11:11:24 UTC) #34
Message was sent while issue was closed.
Change committed as 178044

Powered by Google App Engine
This is Rietveld 408576698