Граф коммитов

1005 Коммитов

Автор SHA1 Сообщение Дата
Nobuyoshi Nakada 3612b1bed8 [Feature #19590] Show the invalid clock argument
Include the failed clock argument in the error message from
`Process.clock_gettime` and `Process.clock_getres`.
2023-04-13 14:07:27 +09:00
Daniel DeLorme 4b100f75d2 [DOC] Clarify behavior of abort() with no argument
Since Ruby 2.7 it prints the message and backtrace of $!

Fixes [Bug #19578]
2023-04-05 07:37:07 -07:00
Aaron Patterson 8525603c72
Revert "Fix transient heap mode"
This reverts commit 87253d047c.

Revert "Implement `Process.warmup`"

This reverts commit ba6ccd8714.
2023-04-04 12:59:14 -07:00
Jean Boussier ba6ccd8714 Implement `Process.warmup`
[Feature #18885]

For now, the optimizations performed are:

  - Run a major GC
  - Compact the heap
  - Promote all surviving objects to oldgen

Other optimizations may follow.
2023-04-04 19:49:08 +02:00
Nobuyoshi Nakada 1d529f382c
PID cache is never cleared where `fork` is not used 2023-04-04 11:29:57 +09:00
Nobuyoshi Nakada 3e7d1cbceb Cache pid itself instead of converted VALUE 2023-03-24 14:22:02 +09:00
Jean Boussier 3563e1383f thread_pthread.c: Use a `fork_gen` to protect against fork instead of getpid()
[Feature #19443]

Until recently most libc would cache `getpid()` so this was a cheap check to make.

However as of glibc version 2.25 the PID cache is removed and calls to getpid() always
invoke the actual system call which significantly degrades the performance of existing applications.

The reason glibc removed the cache is that some libraries were bypassing fork(2)
by issuing system calls themselves, causing stale cache issues.

That isn't a concern for Ruby as bypassing MRI's primitive for forking would
render the VM unusable, so we can safely cache the PID.
2023-03-23 09:08:19 +00:00
Peter Zhu 3210130993 Suppress a compiler warning on GCC in process.c
rb_pid_t is 32 bits on some platforms, which will cause a warning on GCC
due to POSFIXABLE always returning true.

    include/ruby/internal/arithmetic/fixnum.h:43:31: warning: comparison is always true due to limited range of data type [-Wtype-limits]
2023-03-22 17:25:18 -04:00
Nobuyoshi Nakada 758e4db551
Mark cached pid if necessary 2023-03-20 18:08:05 +09:00
Jean Boussier 1db8951d3a Cache `Process.pid`
[Feature #19443]

It's not uncommon for database client and similar network libraries
to protect themselves from Process.fork by regularly checking Process.pid

Until recently most libc would cache `getpid()` so this was a cheap
check to make.

However as of glibc version 2.25 the PID cache is removed and calls to
`getpid()` always invoke the actual system call which significantly degrades
the performance of existing applications.

The reason glibc removed the cache is that some libraries were bypassing
`fork(2)` by issuing system calls themselves, causing stale cache issues.

That isn't a concern for Ruby as bypassing MRI's primitive for forking
would render the VM unusable, so we can safely cache the PID.
2023-03-20 08:21:23 +00:00
Samuel Williams 7fd53eeb46
Remove SIGCHLD `waidpid`. (#7527)
* Remove `waitpid_lock` and related code.

* Remove un-necessary test.

* Remove `rb_thread_sleep_interruptible` dead code.
2023-03-15 19:48:27 +13:00
Samuel Williams ac65ce16e9
Revert SIGCHLD changes to diagnose CI failures. (#7517)
* Revert "Remove special handling of `SIGCHLD`. (#7482)"

This reverts commit 44a0711eab.

* Revert "Remove prototypes for functions that are no longer used. (#7497)"

This reverts commit 4dce12bead.

* Revert "Remove SIGCHLD `waidpid`. (#7476)"

This reverts commit 1658e7d966.

* Fix change to rjit variable name.
2023-03-14 20:07:59 +13:00
Samuel Williams 4dce12bead
Remove prototypes for functions that are no longer used. (#7497) 2023-03-10 23:38:09 +13:00
Samuel Williams 86d38b4520
Accept `sleep(nil)` as sleep forever. (#7484) 2023-03-10 16:40:05 +13:00
Samuel Williams 1658e7d966
Remove SIGCHLD `waidpid`. (#7476)
* Remove `waitpid_lock` and related code.

* Remove un-necessary test.

* Remove `rb_thread_sleep_interruptible` dead code.
2023-03-09 16:05:47 +13:00
Takashi Kokubun 9ad19069f9 Remove obsoleted functions in rjit.c 2023-03-07 23:59:50 -08:00
Takashi Kokubun b67f07fa2c Get rid of MJIT's special fork 2023-03-07 23:08:57 -08:00
Takashi Kokubun 23ec248e48 s/mjit/rjit/ 2023-03-06 23:44:01 -08:00
Takashi Kokubun 2e875549a9 s/MJIT/RJIT/ 2023-03-06 23:44:01 -08:00
zverok 01509f344a [DOC] Restore Process module doc lost due to RDoc update 2023-02-19 22:32:52 +02:00
Maciek Rząsa 50c6cabadc
[DOC] Change formatting in the exec docs
The last part of the sentence was accidentally put in enumeration, It
made an impression that it's one of the rules, not the result of
applying the rules.
2022-11-19 11:38:16 +09:00
S-H-GAMELINKS 1f4f6c9832 Using UNDEF_P macro 2022-11-16 18:58:33 +09:00
Hiroshi SHIBATA 6b0b326ef2 Followed up 796069b288 2022-09-22 11:35:28 +09:00
David Carlier 796069b288 getrlimit adding RLIMIT_NPTS constant. 2022-09-21 18:07:59 +09:00
Koichi ITO e3b178066b [DOC] Tweak the doc for `Process.kill` signature
Replacing `...` with `*pids` seems to clarify the expected variadic arguments.

Note that the expected arguments are two or more with a signal and pids.
That is, the method must have at least one pid, which cannot be omitted:

```console
% ruby -e 'Process.kill(0)'
-e:1:in `kill': wrong number of arguments (given 1, expected 2+) (ArgumentError)
        from -e:1:in `<main>'
```
2022-09-21 15:21:27 +09:00
Nobuyoshi Nakada 55e540f7ab
Ignore EPERM which means already being process-leader 2022-09-20 11:12:11 +09:00
Nobuyoshi Nakada ae07336529 Reduce fork calls in daemon
The forked child process is a grandchild process from the viewpoint of
the process which invoked the caller process.  That means the child is
detached at that point, and it does not need to fork twice.
2022-09-19 15:34:16 +09:00
Takashi Kokubun aa8a3b2358
MJIT: Do not hang after forking with threads
First, rb_mjit_fork should call rb_thread_atfork to stop threads after
fork in the child process. Unfortunately, we cannot use rb_fork_ruby to
prevent this kind of mistakes because MJIT needs special handling of
waiting_pid and mjit_pause/resume.

Second, mjit_waitpid_finished should be checked regardless of
trap_interrupt. It doesn't seem like the flag is not set when SIGCHLD is
handled for an MJIT child process.
2022-09-11 09:09:05 +09:00
Takashi Kokubun f6d569b7c0
Call appropriate hooks on MJIT's fork
This takes care of signal_self_pipe and other things.
2022-09-04 18:22:25 -07:00
Nobuyoshi Nakada b2205cd45c Short-circuit `Process._fork` 2022-08-12 16:57:56 +09:00
Nobuyoshi Nakada e545cfad20
Stop using casted `rb_syswait` as `proc_syswait`
The argument of `rb_syswait` is now `rb_pid_t` which may differ from
`int`.  Also it is an undefined behavior to take the result of casted
void function (in `rb_protect`).
2022-08-07 00:02:38 +09:00
Nobuyoshi Nakada f245b425af
Fix the sizes comparison
`proc_syswait` will be called with a `VALUE` argument.
2022-08-06 23:56:44 +09:00
Ivo Anjo 74817f3d37
[DOC] Process._fork does not get called by Process.daemon
As discussed in [Bug #18911], I'm adding some documentation to
`Process._fork` to clarify that it is not expected to cover
calls to `Process.daemon`.

[Bug #18911]: https://bugs.ruby-lang.org/issues/18911

Co-authored-by: Yusuke Endoh <mame@ruby-lang.org>
2022-08-05 18:40:48 +09:00
Takashi Kokubun 5b21e94beb Expand tabs [ci skip]
[Misc #18891]
2022-07-21 09:42:04 -07:00
Nobuyoshi Nakada 5e66525e41
[DOC] Document `Process::Tms` 2022-06-28 20:19:05 +09:00
Nobuyoshi Nakada a58611dfb1 Allow to just warn as bool expected, without an exception 2022-06-20 19:35:12 +09:00
Takashi Kokubun 1162523bae
Remove MJIT worker thread (#6006)
[Misc #18830]
2022-06-15 09:40:54 -07:00
Peter Zhu 54b53e2c8f [ci skip] Fix docs 2022-04-13 10:43:23 -04:00
Burdette Lamar 70415071e8
Fix some RDoc links (#5778) 2022-04-08 14:25:38 -05:00
Nobuyoshi Nakada 42a0bed351
Prefix ccan headers (#4568)
* Prefixed ccan headers

* Remove unprefixed names in ccan/build_assert

* Remove unprefixed names in ccan/check_type

* Remove unprefixed names in ccan/container_of

* Remove unprefixed names in ccan/list

Co-authored-by: Samuel Williams <samuel.williams@oriontransfer.co.nz>
2022-03-30 20:36:31 +13:00
Thierry Joyal 9cbebdcb74 [DOC] Fix documentation typo for Process#clock_gettime
Fixes [Misc #18610]
2022-03-07 13:02:01 +01:00
Nobuyoshi Nakada 4641abf0a2 Use symbols for clock IDs if `clockid_t` is not numeric 2022-02-19 15:33:15 +09:00
Nobuyoshi Nakada b3de25dfee Set static IDs to same name variables 2022-02-19 15:33:15 +09:00
Burdette Lamar e9a2b30744
Enhanced RDoc concerning command injection (#5537)
Clarifies security vulnerabilities for commands.

Treats:

    Kernel.system
    Kernel.` (backtick)
    IO.popen
    IO.read
    IO.write
    IO.binread
    IO.binwrite
    IO.readlines
    IO.foreach
2022-02-18 06:46:04 -06:00
Kevin Newton fc6fd4c31e Accurately report VM memsize
Currently the calculation only counts the size of the struct. This commit adds the size of the associated st tables, id tables, and linked lists.

Still missing is the size of the ractors and (potentially) the size of the object space.
2022-01-21 14:34:53 -08:00
Nobuyoshi Nakada 2f0f56bdca
[DOC] Enhanced Process.groups related
* On some platforms (e.g., macOS), the user's default group access
  list may exceed `NGROUPS_MAX`.
* Use upcase "GID" instead of "gid" for other than variable names.
2022-01-19 12:04:08 +09:00
Peter Zhu ffda21b7ba [Feature #18491] Drop support for HP-UX
IA64 support was dropped in ticket #15894, so we can drop support for
HP-UX.
2022-01-18 09:52:15 -05:00
S-H-GAMELINKS 804a714971 Replace to RBOOL macro 2022-01-17 13:49:37 +09:00
Matheus Richard b563f12297
[DOC] Fix docs rendering for Process._fork [ci skip]
Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
2021-12-15 07:15:02 +09:00
S.H 75aae66c4f
Some codes replace to `RBOOL` macro (#5023)
* Some code replace and using RBOOL macro

* Fix indent

* Using RBOOL in syserr_eqq function
2021-11-09 17:09:29 +09:00