https://redmine.ruby-lang.org/https://redmine.ruby-lang.org/favicon.ico?17113305112020-06-27T19:12:37ZRuby Issue Tracking SystemRuby master - Feature #16984: Remove write barrier exemption for T_ICLASShttps://redmine.ruby-lang.org/issues/16984?journal_id=863682020-06-27T19:12:37Zko1 (Koichi Sasada)
<ul></ul><p>Thank you for great work. This kind of hack can cause BUGs easily.</p>
<blockquote>
<p>Private app A's heap size is about 22 MiB compared to B's 250 MiB.</p>
</blockquote>
<p>Could you measure the memory/objects consumption before and after this patch if it is not difficult?<br>
Maybe no problem, but I want to confirm.</p> Ruby master - Feature #16984: Remove write barrier exemption for T_ICLASShttps://redmine.ruby-lang.org/issues/16984?journal_id=863742020-06-30T07:13:05Zalanwu (Alan Wu)
<ul></ul><blockquote>
<p>Could you measure the memory/objects consumption before and after this patch if it is not difficult?</p>
</blockquote>
<p>I took measurements on app B. It's a large Rails app with lots of classes and modules.<br>
The amount of retained memory is not deterministic unfortunately, so I can only give a rough summary.</p>
<pre><code> | Change to median | Change to average |
</code></pre>
<p>--------------------------|--------------------|---------------------|<br>
GC::Profiler "Total Size" | 7 MiB | 1 MiB |<br>
VmRSS from the /proc | 4 MiB | -5 MiB |</p>
<p>The increase to GC heap size makes sense, I expect about 5 MiB more objects given the number of<br>
classes and modules in the app. There is not much change to RSS I guess because the<br>
patch moves what used to be on the malloc heap to the GC heap.</p> Ruby master - Feature #16984: Remove write barrier exemption for T_ICLASShttps://redmine.ruby-lang.org/issues/16984?journal_id=865372020-07-13T21:51:32Zalanwu (Alan Wu)
<ul><li><strong>Description</strong> updated (<a title="View differences" href="/journals/86537/diff?detail_id=57493">diff</a>)</li></ul><p>Edit: I noticed that T_ICLASS wasn't marking the shared method and constant table on master. My notes<br>
about reducing the number of <code>gc_mark</code> references on the heap were incorrect.</p> Ruby master - Feature #16984: Remove write barrier exemption for T_ICLASShttps://redmine.ruby-lang.org/issues/16984?journal_id=870292020-08-12T06:28:09Zko1 (Koichi Sasada)
<ul></ul><p>sorry I didn't check it.</p>
<p>Thank you, ~10 MB in "B's 250 MiB." is not problem I think.<br>
Could you merge it if you don't have any trouble more?</p> Ruby master - Feature #16984: Remove write barrier exemption for T_ICLASShttps://redmine.ruby-lang.org/issues/16984?journal_id=870432020-08-13T03:31:21Zalanwu (Alan Wu)
<ul><li><strong>Subject</strong> changed from <i>Remove write barrier examption for T_ICLASS</i> to <i>Remove write barrier exemption for T_ICLASS</i></li><li><strong>Description</strong> updated (<a title="View differences" href="/journals/87043/diff?detail_id=57735">diff</a>)</li></ul> Ruby master - Feature #16984: Remove write barrier exemption for T_ICLASShttps://redmine.ruby-lang.org/issues/16984?journal_id=870442020-08-13T03:51:05Zalanwu (Alan Wu)
<ul><li><strong>Description</strong> updated (<a title="View differences" href="/journals/87044/diff?detail_id=57736">diff</a>)</li></ul> Ruby master - Feature #16984: Remove write barrier exemption for T_ICLASShttps://redmine.ruby-lang.org/issues/16984?journal_id=870452020-08-13T03:55:02Zalanwu (Alan Wu)
<ul><li><strong>Description</strong> updated (<a title="View differences" href="/journals/87045/diff?detail_id=57737">diff</a>)</li></ul> Ruby master - Feature #16984: Remove write barrier exemption for T_ICLASShttps://redmine.ruby-lang.org/issues/16984?journal_id=870992020-08-17T21:16:20Zalanwu (Alan Wu)
<ul><li><strong>Description</strong> updated (<a title="View differences" href="/journals/87099/diff?detail_id=57755">diff</a>)</li></ul> Ruby master - Feature #16984: Remove write barrier exemption for T_ICLASShttps://redmine.ruby-lang.org/issues/16984?journal_id=871002020-08-17T21:18:07Zalanwu (Alan Wu)
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Closed</i></li></ul><p>Applied in changeset <a class="changeset" title="Remove write barrier exemption for T_ICLASS Before this commit, iclasses were "shady", or not pr..." href="https://redmine.ruby-lang.org/projects/ruby-master/repository/git/revisions/264e4cd04fbcdcb739a1ff9a84e19afe66005cb2">git|264e4cd04fbcdcb739a1ff9a84e19afe66005cb2</a>.</p>
<hr>
<p>Remove write barrier exemption for T_ICLASS</p>
<p>Before this commit, iclasses were "shady", or not protected by write<br>
barriers. Because of that, the GC needs to spend more time marking these<br>
objects than otherwise.</p>
<p>Applications that make heavy use of modules should see reduction in GC<br>
time as they have a significant number of live iclasses on the heap.</p>
<ul>
<li>Put logic for iclass method table ownership into a function</li>
<li>Remove calls to WB_UNPROTECT and insert write barriers for iclasses</li>
</ul>
<p>This commit relies on the following invariant: for any non oirigin<br>
iclass <code>I</code>, <code>RCLASS_M_TBL(I) == RCLASS_M_TBL(RBasic(I)->klass)</code>. This<br>
invariant did not hold prior to 98286e9 for classes and modules that<br>
have prepended modules.</p>
<p>[Feature <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: Remove write barrier exemption for T_ICLASS (Closed)" href="https://redmine.ruby-lang.org/issues/16984">#16984</a>]</p>