https://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17097754782013-11-26T18:54:13ZRuby Issue Tracking SystemRuby master - Bug #9159: [patch] use rb_fstring for internal stringshttps://bugs.ruby-lang.org/issues/9159?journal_id=431682013-11-26T18:54:13Ztmm1 (Aman Karmani)ruby@tmm1.net
<ul></ul><p>One example of strings de-duplicated by this patch are iseq labels. Before:</p>
<p>irb(main):001:0> mm = "method_missing"<br>
irb(main):002:0> GC.start; ObjectSpace.each_object(String).select{ |o| o == mm }.size<br>
=> 77</p>
<p>After:</p>
<p>irb(main):002:0> GC.start; ObjectSpace.each_object(String).select{ |o| o == mm }.size<br>
=> 3</p> Ruby master - Bug #9159: [patch] use rb_fstring for internal stringshttps://bugs.ruby-lang.org/issues/9159?journal_id=431692013-11-26T18:56:46Ztmm1 (Aman Karmani)ruby@tmm1.net
<ul></ul><blockquote>
<p>if (nd_type(node) == NODE_STR) {</p>
<ul>
<li>
<pre><code>hide_obj(node->nd_lit);
</code></pre>
</li>
</ul>
<ul>
<li>
<pre><code>node->nd_lit = rb_fstring(node->nd_lit);
ADD_INSN1(ret, nd_line(node), putobject, node->nd_lit);
</code></pre>
</li>
</ul>
</blockquote>
<p>Some internal strings are no longer hidden with this patch, since the underlying T_STRING object can be shared via the fstr table.<br>
Since the object is already marked immutable (via the frozen flag), hiding it is unnecessary.</p> Ruby master - Bug #9159: [patch] use rb_fstring for internal stringshttps://bugs.ruby-lang.org/issues/9159?journal_id=431812013-11-27T08:26:00Zsam.saffron (Sam Saffron)sam.saffron@gmail.com
<ul></ul><p>Seeing similar results for Discourse:</p>
<p><a href="https://gist.github.com/SamSaffron/7668043" class="external">https://gist.github.com/SamSaffron/7668043</a></p> Ruby master - Bug #9159: [patch] use rb_fstring for internal stringshttps://bugs.ruby-lang.org/issues/9159?journal_id=431822013-11-27T08:30:29Ztmm1 (Aman Karmani)ruby@tmm1.net
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Closed</i></li><li><strong>% Done</strong> changed from <i>0</i> to <i>100</i></li></ul><p>This issue was solved with changeset r43866.<br>
Aman, thank you for reporting this issue.<br>
Your contribution to Ruby is greatly appreciated.<br>
May Ruby be with you.</p>
<hr>
<ul>
<li>compile.c: Use rb_fstring() to de-duplicate string literals in code. <a href="/issues/9159">[ruby-core:58599]</a> [Bug <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Bug: [patch] use rb_fstring for internal strings (Closed)" href="https://bugs.ruby-lang.org/issues/9159">#9159</a>] <a href="/issues/8148">[ruby-core:54405]</a></li>
<li>iseq.c (prepare_iseq_build): De-duplicate iseq labels and source locations.</li>
<li>re.c (rb_reg_initialize): Use rb_fstring() for regex string.</li>
<li>string.c (rb_fstring): Handle non-string and already-fstr arguments.</li>
<li>vm_eval.c (eval_string_with_cref): De-duplicate eval source filename.</li>
</ul> Ruby master - Bug #9159: [patch] use rb_fstring for internal stringshttps://bugs.ruby-lang.org/issues/9159?journal_id=431832013-11-27T08:53:11Znormalperson (Eric Wong)normalperson@yhbt.net
<ul></ul><p>Can somebody following this thread check out my patch for<br>
<a href="https://bugs.ruby-lang.org/issues/8998" class="external">https://bugs.ruby-lang.org/issues/8998</a></p>
<p>Theoretically it should be better than nothing (but not ideal), but I<br>
don't think any of my code uses string hash keys enough to matter...<br>
Thanks.</p>