This patch introduce M:N thread scheduler for Ractor system.
In general, M:N thread scheduler employs N native threads (OS threads)
to manage M user-level threads (Ruby threads in this case).
On the Ruby interpreter, 1 native thread is provided for 1 Ractor
and all Ruby threads are managed by the native thread.
From Ruby 1.9, the interpreter uses 1:1 thread scheduler which means
1 Ruby thread has 1 native thread. M:N scheduler change this strategy.
Because of compatibility issue (and stableness issue of the implementation)
main Ractor doesn't use M:N scheduler on default. On the other words,
threads on the main Ractor will be managed with 1:1 thread scheduler.
There are additional settings by environment variables:
`RUBY_MN_THREADS=1` enables M:N thread scheduler on the main ractor.
Note that non-main ractors use the M:N scheduler without this
configuration. With this configuration, single ractor applications
run threads on M:1 thread scheduler (green threads, user-level threads).
`RUBY_MAX_CPU=n` specifies maximum number of native threads for
M:N scheduler (default: 8).
This patch will be reverted soon if non-easy issues are found.
[Bug #19842]
(https://github.com/ruby/irb/pull/648)
IRB already has several features that rely on rdoc, such as:
- Autocompletion's document dialog
- Autocompletion's `PerfectMatchedProc`
- The `show_doc` command
- Easter egg
And we could use its pager more in the future too. So it makes sense to
declare rdoc as a dependency instead of relying on the one bundled with
Ruby.
https://github.com/ruby/irb/commit/4dffbb1dd3
This returns a Dir instance for the given directory file descriptor.
If fdopendir is not supported, this raises NotImplementedError.
Implements [Feature #19347]
This is useful for passing directory file descriptors over UNIX
sockets or to child processes to avoid TOCTOU vulnerabilities.
The implementation follows the Dir.chdir code.
This will raise NotImplementedError on platforms not supporting
both fchdir and dirfd.
Implements [Feature #19347]
Dir.glob brace pattern with '/' after '**' does not match
paths in recursive expansion process.
We expand braces with '/' before expanding a recursive.
Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
When using `IFTODT` defined in libc, `dirent.d_type` oriented pathtype
is compatible with `IFTODT(stat.st_mode)`. However they are not
compatible when emulating `IFTODT`, so `glob_helper` has to stat instead
of reusing dirent result by passing unknown pathtype to `glob_helper`.
This is a follow-up fix of 0c90ca4dd0
dir.c defines IFTODT if the system doesn't have it. The macro is used
when comparing with rb_pathtype_t's cases. rb_pathtype_t's cases are
defined by DT_XXX macro if they are available, or defined using IFTODT.
Most POSIX-compatible platforms have both IFTODT and DT_XXX and most of
other platforms like MinGW have neither of them. On those platforms,
DT_XXX-oriented rb_pathtype_t is always compared with values converted
by system's IFTODT, and emulated-IFTODT-oriented rb_pathtype_t is always
compared with values converted by emulated-IFTODT.
However, when IFTODT is *not defined* and DT_XXX is *defined*, like
on wasi-libc, DT_XXX-oriented rb_pathtype_t was compared with values
converted by emulated-IFTODT, and they are not guaranteed to be
compatible.
This patch fixes such a situation by using emulated-IFTODT to define
rb_pathtype_t when either IFTODT or DT_XXX is not available.
This was already documented as being ignored, but it wasn't being
ignored, causing an issue in a particular case where a UTF-8
pattern was provided and a filename was tested that wasn't valid
UTF-8.
Fixes [Bug #14456]
The documentation already stated this was an error in one case
(when it was previously a warning). Describe the other case,
where chdir without block is called inside block passed to chdir.
Fixes [Bug #15661]
RARRAY_AREF has been a macro for reasons. We might not be able to
change that for public APIs, but why not relax the situation internally
to make it an inline function.