|
| 1 | +2015-11-20 Andreas Kling < [email protected]> |
| 2 | + |
| 3 | + GC timers should carry on gracefully when Heap claims it grew from GC. |
| 4 | + <https://webkit.org/b/151521> |
| 5 | + |
| 6 | + Reviewed by Mark Lam. |
| 7 | + |
| 8 | + TL;DR the Heap "extra memory" reporting APIs are hard to use 100% correctly |
| 9 | + and GC scheduling shouldn't break if someone makes a mistake with it. |
| 10 | + |
| 11 | + The JSC::Heap allows you to report an extra memory cost for any GC object. |
| 12 | + This is reported first when allocating the memory, and then each time the |
| 13 | + object is visited during the marking phase. |
| 14 | + |
| 15 | + When reporting an allocation, it's added to the Heap's "bytes allocated in |
| 16 | + this cycle" counter. This contributes to the computed heap size at the start |
| 17 | + of a collection. |
| 18 | + |
| 19 | + When visiting a GC object that reports extra memory, it's added to the Heap's |
| 20 | + "extra memory visited in this collection" counter. This contributes to the |
| 21 | + computed heap size at the end of a collection. |
| 22 | + |
| 23 | + As you can see, this means that visiting more memory than we said we allocated |
| 24 | + can lead to the Heap thinking it's bigger after a collection than it was before. |
| 25 | + |
| 26 | + Clients of this API do some sketchy things to compute costs, for instance |
| 27 | + StringImpl cost is determined by dividing the number of bytes used for the |
| 28 | + characters, and dividing it by the StringImpl's ref count. Since a JSString |
| 29 | + could be backed by any StringImpl, any code that modifies a StringImpl's |
| 30 | + ref count during collection will change the extra memory reported by all |
| 31 | + JSString objects that wrap that StringImpl. |
| 32 | + |
| 33 | + So anyways... |
| 34 | + |
| 35 | + The object death rate, which is the basis for when to schedule the next |
| 36 | + collection is computed like so: |
| 37 | + |
| 38 | + deathRate = (sizeBeforeGC - sizeAfterGC) / sizeBeforeGC |
| 39 | + |
| 40 | + This patch adds a safety mechanism that returns a zero death rate when the Heap |
| 41 | + claims it grew from collection. |
| 42 | + |
| 43 | + * heap/EdenGCActivityCallback.cpp: |
| 44 | + (JSC::EdenGCActivityCallback::deathRate): |
| 45 | + * heap/FullGCActivityCallback.cpp: |
| 46 | + (JSC::FullGCActivityCallback::deathRate): |
| 47 | + |
1 | 48 | 2015-11-20 Mark Lam < [email protected]>
|
2 | 49 |
|
3 | 50 | New JSC tests introduced in r192664 fail on ARM.
|
|
0 commit comments