Ruby Issue Tracking System: Issueshttps://redmine.ruby-lang.org/https://redmine.ruby-lang.org/favicon.ico?17113305112023-02-25T01:48:35ZRuby Issue Tracking System
Redmine Ruby master - Feature #19465 (Assigned): [PATCH] reuse open(2) from rb_file_load_ok on POSIX-like...https://redmine.ruby-lang.org/issues/194652023-02-25T01:48:35Znormalperson (Eric Wong)normalperson@yhbt.net
<pre><code>When loading Ruby source files, we can save the result of
successful opens as open(2)/openat(2) are a fairly expensive
syscalls. This also avoids a time-of-check-to-time-of-use
(TOCTTOU) problem.
This reduces open(2) syscalls during `require'; but should be
most apparent when users have a small $LOAD_PATH. Users with
large $LOAD_PATH will benefit less since there'll be more
open(2) failures due to ENOENT.
With `strace -c -e openat ruby -e exit' under Linux, this
results in a ~14% reduction of openat(2) syscalls
(glibc uses openat(2) to implement open(2)).
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
0.00 0.000000 0 296 110 openat
0.00 0.000000 0 254 110 openat
Additionally, the introduction of `struct ruby_file_load_state'
may make future optimizations more apparent.
This change cannot benefit binary (.so) loading since the
dlopen(3) API requires a filename and I'm not aware of an
alternative that takes a pre-existing FD. In typical
situations, Ruby source files outnumber the mount of .so
files.
I've only tested this lightly on small apps since I don't have
large codebases to test on. However, I think organizing various
on-stack variables into `struct ruby_file_load_state' can be
beneficial if we end up using io-uring on Linux.
</code></pre> Ruby master - Feature #14901 (Assigned): [PATCH] do not block SIGCHLD in normal Ruby Threadshttps://redmine.ruby-lang.org/issues/149012018-07-08T02:53:23Znormalperson (Eric Wong)normalperson@yhbt.net
<p><a class="user active user-mention" href="https://redmine.ruby-lang.org/users/10073">@k0kubun (Takashi Kokubun)</a>: any opinions on this? Thanks.</p>
<pre><code>I blocked SIGCHLD in normal Ruby Threads for [Bug #14867]
because I noticed at least two places which could not deal
with spurious wakeups in our test suite.
I also want to get rid of timer-thread due to resource
limitations <a href="https://blade.ruby-lang.org/ruby-core/87773">[ruby-core:87773]</a>. MJIT causes many SIGCHLD signals
so I found the following problems with cppflags=-DMJIT_FORCE_ENABLE=1
* OpenSSL::PKey::*.new does not resume on handle signals.
rhenium acknowledged the problem and it should be in trunk soon:
https://bugs.ruby-lang.org/issues/14882
* test/-ext-/gvl/test_last_thread.rb does not handle spurious
wakeups. Original report is in Japanese:
https://bugs.ruby-lang.org/issues/11237
I don't think it's a realistic expectation for code to be
unable to deal with spurious wakeups.
One alternative could be to handle signals with MJIT thread
when MJIT is enabled, or to lazy-spawn timer thread to handle
signals when MJIT is enabled (MJIT + gcc requires a lot of
resources, anyways).
</code></pre> Ruby master - Feature #11299 (Open): [PATCH] use Array instead of custom struct for generic ivarshttps://redmine.ruby-lang.org/issues/112992015-06-23T23:23:15Znormalperson (Eric Wong)normalperson@yhbt.net
<p>I'll commit this in a few days unless there's an objection.</p>
<pre><code>This reduces both code and object size while reducing the cognitive
overhead necessary to understand the code. Memory usage should be
slightly higher due to Array overheads, but still better than what we
had in Ruby 2.2 and earlier.
text data bss dec hex filename
2837117 22688 71576 2931381 2cbab5 ruby.before
2836221 22688 71576 2930485 2cb735 ruby.after
array.c | 28 +++++-----
internal.h | 1 +
variable.c | 170 +++++++++++++++++++------------------------------------------
3 files changed, 69 insertions(+), 130 deletions(-)
* array.c (rb_mem_clear): use memfill
(rb_ary_store_fill): new function
(rb_ary_store): use rb_ary_store_fill
* internal.h (rb_ary_store_fill): new declaration
* variable.c (struct gen_ivtbl): remove
(struct ivar_update): adjust type
(struct gen_ivar_compat_tbl): ditto
(struct gen_ivar_tag): ditto
(struct givar_copy): ditto
(gen_ivar_compat_tbl_i): adjust for type change
(gen_ivtbl_get): ditto
(generic_ivar_delete): ditto
(generic_ivar_get): ditto
(generic_ivar_update): ditto
(generic_ivar_defined): ditto
(rb_mark_generic_ivar): ditto
(rb_free_generic_ivar): ditto
(rb_generic_ivar_memsize): ditto
(generic_ivar_set): ditto
(gen_ivtbl_count): ditto
(gen_ivar_each_i): ditto
(gen_ivar_copy): ditto
(rb_copy_generic_ivar): ditto
(rb_ivar_count): ditto
(gen_ivtbl_bytes): remove
(gen_ivtbl_resize): remove
(gen_ivtbl_dup): remove
(gen_ivtbl_mark): remove
</code></pre> Ruby master - Feature #10328 (Open): [PATCH] make OPT_SUPPORT_JOKE a proper VM optionhttps://redmine.ruby-lang.org/issues/103282014-10-05T21:14:21Znormalperson (Eric Wong)normalperson@yhbt.net
<p>This is not a joke :)</p>
<p>I worry about executable size with things like [Feature <a class="issue tracker-2 status-6 priority-4 priority-default closed" title="Feature: [PATCH] optimize: recv << "literal string" (Rejected)" href="https://redmine.ruby-lang.org/issues/10326">#10326</a>],<br>
and I noticed unused instructions are emitted even with jokes disabled</p>
<p>This reduces executable size slightly on x86-64-linux:</p>
<p>text | data | bss | dec | hex | filename<br>
--------+-------+--------+---------+--------+------------<br>
2782156 | 22400 | 71880 | 2876436 | 2be414 | ruby.before<br>
2781420 | 22400 | 71880 | 2875700 | 2be134 | ruby.after</p>
<p>Pretty trivial so I'll commit in a day or two.</p>
<hr>
<pre><code> compile.c | 4 ++--
eval.c | 2 +-
iseq.h | 2 +-
tool/instruction.rb | 9 ++++++---
vm_opts.h | 2 +-
5 files changed, 11 insertions(+), 8 deletions(-)
</code></pre>