[#112457] [Ruby master Feature#19443] Cache `Process.pid` — "byroot (Jean Boussier) via ruby-core" <ruby-core@...>
Issue #19443 has been reported by byroot (Jean Boussier).
16 messages
2023/02/16
[#112584] [Ruby master Feature#19465] [PATCH] reuse open(2) from rb_file_load_ok on POSIX-like system — "normalperson (Eric Wong) via ruby-core" <ruby-core@...>
Issue #19465 has been reported by normalperson (Eric Wong).
9 messages
2023/02/25
[#112595] [Ruby master Feature#19465] [PATCH] reuse open(2) from rb_file_load_ok on POSIX-like system
— "nobu (Nobuyoshi Nakada) via ruby-core" <ruby-core@...>
2023/02/25
SXNzdWUgIzE5NDY1IGhhcyBiZWVuIHVwZGF0ZWQgYnkgbm9idSAoTm9idXlvc2hpIE5ha2FkYSku
[#112613] Re: [Ruby master Feature#19465] [PATCH] reuse open(2) from rb_file_load_ok on POSIX-like system
— Eric Wong via ruby-core <ruby-core@...>
2023/02/26
"nobu (Nobuyoshi Nakada) via ruby-core" <ruby-core@ml.ruby-lang.org> wrote:
[#112615] Re: [Ruby master Feature#19465] [PATCH] reuse open(2) from rb_file_load_ok on POSIX-like system
— SHIBATA Hiroshi via ruby-core <ruby-core@...>
2023/02/27
MzUxMzZlMWU5YzIzMmFkN2EwMzQwN2I5OTJiMmU4NmI2ZGY0M2Y2MyBpcyBicm9rZW4gd2l0aCBg
[#112626] Re: [Ruby master Feature#19465] [PATCH] reuse open(2) from rb_file_load_ok on POSIX-like system
— Eric Wong via ruby-core <ruby-core@...>
2023/02/28
```
[ruby-core:112627] [Ruby master Feature#19465] [PATCH] reuse open(2) from rb_file_load_ok on POSIX-like system
From:
ruby-core--- via ruby-core <ruby-core@...>
Date:
2023-02-28 09:40:27 UTC
List:
ruby-core #112627
Issue #19465 has been updated by hsbt (Hiroshi SHIBATA).
Copy Eric's message from [ruby-core:112626](https://ml.ruby-lang.org/mailman3/hyperkitty/list/ruby-core@ml.ruby-lang.org/message/GJTGY77GFCGBOAIFTSLEYYGO2ENSDR52/)
> 35136e1e9c232ad7a03407b992b2e86b6df43f63 is broken with `gcc-11 annocheck`.
>
> Its configuration is here:
> https://git.ruby-lang.org/ruby.git/tree/.github/workflows/compilers.yml#n82
default_cc: 'gcc-11 -fcf-protection -Wa,--generate-missing-build-notes=yes'
optflags: '-O2'
LDFLAGS: '-Wl,-z,now'
OK, only gcc11-available system I have is a FreeBSD VM and I
couldn't reproduce it with those flags, (no podman/docker on
FreeBSD).
> 69 1) An exception occurred during: Kernel#require_relative with a
> relative path (file extensions) does not load a C-extension file if a
> complex-extensioned .rb file is already loaded
> 70 /__w/ruby/ruby/src/spec/ruby/core/kernel/require_relative_spec.rb:197
> 71 Kernel#require_relative with a relative path (file extensions) does
> not load a C-extension file if a complex-extensioned .rb file is
> already loaded ERROR
> 72 LeakError: Leaked file descriptor: 8 :
> #<File:/__w/ruby/ruby/src/spec/ruby/fixtures/code/load_fixture.ext.rb>
I saw similar errors in development, but thought I fixed them all.
Where there other CI instances which failed or just the annocheck one?
I can't find failures for 35136e1e9 in http://ci.rvm.jp/failure_results
Is there a machine/VM I can ssh/mosh into which reproduces that issue?
Thanks.
----------------------------------------
Feature #19465: [PATCH] reuse open(2) from rb_file_load_ok on POSIX-like system
https://bugs.ruby-lang.org/issues/19465#change-102078
* Author: normalperson (Eric Wong)
* Status: Assigned
* Priority: Normal
* Assignee: normalperson (Eric Wong)
----------------------------------------
```
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.
```
---Files--------------------------------
0001-reuse-open-2-from-rb_file_load_ok-on-POSIX-like-syst.patch (15.2 KB)
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/