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

77900 Коммитов

Автор SHA1 Сообщение Дата
Hiroshi SHIBATA 35da41b29b
Revert https://github.com/ruby/io-console/pull/43
This reverts commit 1889133c04 and
  commit 764207e47c.

  Followed up with 85dcc4866d
2023-06-01 09:36:55 +09:00
NARUSE, Yui 85dcc4866d Revert "Hide most of the implementation of `struct rb_io`. (#6511)"
This reverts commit 18e55fc1e1.

fix [Bug #19704]
https://bugs.ruby-lang.org/issues/19704
This breaks compatibility for extension libraries. Such changes
need a discussion.
2023-06-01 08:43:22 +09:00
Peter Zhu e4163112f6 More debug code to GC compaction test 2023-05-31 16:16:50 -04:00
Peter Zhu e8212c55f9 Fix flaky test in test_objspace.rb
Ensure that the frozen string is promoted to the old generation by
running the GC 4 times.
2023-05-31 14:03:30 -04:00
Benoit Daloze 55c9c658bd ruby/spec no longer supports 2.7 since it is EOL 2023-05-31 18:11:18 +02:00
Peter Zhu 1ac17693de Add debug code to GC compaction test
This test is flaky on some CI systems.
2023-05-31 09:22:52 -04:00
Nobuyoshi Nakada e502600fb9
Assertion on message length for the `-h` option 2023-05-31 15:15:59 +09:00
Hiroshi SHIBATA 3bc5f6b240
[rubygems/rubygems] tool_dir needs to handle ruby/ruby repo now
https://github.com/rubygems/rubygems/commit/550d90f4ba
2023-05-31 13:55:30 +09:00
Takashi Kokubun 1f74e25c3b
YJIT: Force showing a backtrace on panic (#7869) 2023-05-30 11:20:02 -04:00
Hiroshi SHIBATA 4bbeed6134 Merge RubyGems/Bundler master from 4076391fce5847689bf2ec402b17133fe4e32285 2023-05-30 21:50:07 +09:00
Benoit Daloze 30b960ba34 [ruby/io-nonblock] Add TruffleRuby support and add it in CI
* Do not use a C extension on TruffleRuby for these 3 methods.

https://github.com/ruby/io-nonblock/commit/1b8e52abfa
2023-05-30 12:39:26 +00:00
Benoit Daloze c7c8e4c96e [ruby/io-nonblock] Use the correct pattern for the fallback of rb_io_descriptor()
* See d1d9aef45c

https://github.com/ruby/io-nonblock/commit/dadb42422b
2023-05-30 12:39:25 +00:00
Jeremy Evans ec9364e500 [ruby/racc] Remove ErrorSymbolValue reference
I cannot find where this is defined.  I'm guessing neither this
nor the else branch is ever hit.  I only found out when testing
VM changes, which had a bug that exposed this.

https://github.com/ruby/racc/commit/8983d0c134
2023-05-30 01:43:48 +00:00
Samuel Williams 18e55fc1e1
Hide most of the implementation of `struct rb_io`. (#6511)
* Add rb_io_path and rb_io_open_descriptor.

* Use rb_io_open_descriptor to create PTY objects

* Rename FMODE_PREP -> FMODE_EXTERNAL and expose it

FMODE_PREP I believe refers to the concept of a "pre-prepared" file, but
FMODE_EXTERNAL is clearer about what the file descriptor represents and
aligns with language in the IO::Buffer module.

* Ensure that rb_io_open_descriptor closes the FD if it fails

If FMODE_EXTERNAL is not set, then it's guaranteed that Ruby will be
responsible for closing your file, eventually, if you pass it to
rb_io_open_descriptor, even if it raises an exception.

* Rename IS_EXTERNAL_FD -> RUBY_IO_EXTERNAL_P

* Expose `rb_io_closed_p`.

* Add `rb_io_mode` to get IO mode.

---------

Co-authored-by: KJ Tsanaktsidis <ktsanaktsidis@zendesk.com>
2023-05-30 10:02:40 +09:00
dependabot[bot] 7ddcd0622f [rubygems/rubygems] Bump rb-sys
Bumps [rb-sys](https://github.com/oxidize-rb/rb-sys) from 0.9.77 to 0.9.78.
- [Release notes](https://github.com/oxidize-rb/rb-sys/releases)
- [Commits](https://github.com/oxidize-rb/rb-sys/compare/v0.9.77...v0.9.78)

---
updated-dependencies:
- dependency-name: rb-sys
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-29 21:24:22 +00:00
Benoit Daloze f61bd3ca80 [ruby/cgi] Add TruffleRuby support and add it in CI
https://github.com/ruby/cgi/commit/1240fec9c9
2023-05-29 19:33:38 +00:00
Benoit Daloze 610038f3bf [ruby/etc] Use the correct pattern for the fallback of rb_io_descriptor()
* See d1d9aef45c

https://github.com/ruby/etc/commit/5185685003
2023-05-29 19:31:55 +00:00
Benoit Daloze 99ce41564e Refactor guards for Time.new spec 2023-05-29 18:33:51 +02:00
Peter Zhu b7a26dfa16 Unify error messages of rb_num2ulong and rb_num2ull
The error messages were slightly different due, which causes different
behaviour on 32-bit and 64-bit systems.
2023-05-29 11:55:39 -04:00
Benoit Daloze c48d496e8c Update to ruby/spec@c3677cf 2023-05-29 15:27:57 +02:00
Samuel Williams 98f500d095
[ruby/openssl] Remove usage of IO internals. 2023-05-29 22:01:58 +09:00
Samuel Williams 764207e47c [ruby/io-console] Remove trailing whitespace.
https://github.com/ruby/io-console/commit/55f1586463
2023-05-29 12:37:49 +00:00
Samuel Williams 1889133c04 [ruby/io-console] Remove usage of IO internals.
(https://github.com/ruby/io-console/pull/43)

https://github.com/ruby/io-console/commit/4b839a504f

Co-authored-by: Benoit Daloze <eregontp@gmail.com>
2023-05-29 12:30:32 +00:00
Jun Aruga 57459b83a9
mkmf: Add the extra option `--with-verbose` to enable verbose mode. (#7863)
This commit is to add an extra option to enable verbose mode (V=1) in the
generated `Makefile` at runtime of the Ruby to print compiler command lines by
the commands below when building native extensions. It's possible to enable the
verbose mode by setting the environment variable `MAKEFLAGS="V=1"`[1]
implemented in GNU make. However, I wanted to make a consistent user-interface
not depending on the specific make's implementation.

```
$ ruby /path/to/extconf.rb -- --with-verbose
```

You can also add the extra option via rake-compiler gem.

```
$ rake compiler -- --with-verbose
```

If the extra option is not given, the value of the
`RbConfig::CONFIG["MKMF_VERBOSE"]` enabled by the configure option below is
used.

```
$ ./configure --enable-mkmf-verbose
```

For the unit tests, updated the following files.

* The `test/mkmf/test_configuration.rb` was created to test the cases with the
  `configuration` method and this implementation.
* Updated the `TestMkmf#assert_separately` to set the extra
  arguments in `test/mkmf/base.rb`. Updated tests using the `assert_separately`.
* Added tests for `MakeMakefile#with_config` in the `test/mkmf/test_config.rb`.

[1] https://www.gnu.org/software/make/manual/html_node/Variables_002fRecursion.html

Fixes [Bug #19695]

Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
2023-05-29 10:09:32 +02:00
tomoya ishida d5ef373b11 [ruby/irb] Set maximum document dialog height by
preferred_dialog_height provided by Reline
(https://github.com/ruby/irb/pull/591)

https://github.com/ruby/irb/commit/df6907aca9
2023-05-28 09:20:18 +00:00
Samuel Williams 14abb799c9 [ruby/io-nonblock] Remove usage of IO internals.
(https://github.com/ruby/io-nonblock/pull/11)

https://github.com/ruby/io-nonblock/commit/caa2b94d19
2023-05-28 08:40:38 +00:00
Samuel Williams 55393645a1 [ruby/io-nonblock] Revert "Remove usage of IO internals."
This reverts commit https://github.com/ruby/io-nonblock/commit/9772b6dcb63c.

https://github.com/ruby/io-nonblock/commit/08cabf78e1
2023-05-28 08:01:50 +00:00
Samuel Williams 26dd9c5f0f [ruby/io-nonblock] Remove usage of IO internals.
https://github.com/ruby/io-nonblock/commit/9772b6dcb6
2023-05-28 07:49:33 +00:00
Samuel Williams 881757c03f [ruby/io-wait] Remove usage of IO internals.
(https://github.com/ruby/io-wait/pull/25)

https://github.com/ruby/io-wait/commit/e5854b46c7
2023-05-28 05:09:02 +00:00
Samuel Williams 00d6674636 [ruby/etc] Remove usage of IO internals.
(https://github.com/ruby/etc/pull/26)

https://github.com/ruby/etc/commit/ea15eceb13
2023-05-28 05:08:40 +00:00
tomoya ishida cf0b9e0db0 [ruby/reline] Fix scrolldown condition in dialog rendering
(https://github.com/ruby/reline/pull/541)

https://github.com/ruby/reline/commit/ad6faada3f
2023-05-27 15:07:29 +00:00
tomoya ishida 5d137a7f77 [ruby/reline] Use appropriate dialog height and reduce screen pushup
problem
(https://github.com/ruby/reline/pull/542)

* Provide preferred_dialog_height for dialog positioning

* Fix rendering test
2023-05-27 14:48:50 +00:00
Samuel Williams bf1bc5362e
Improve `read`/`write`/`pread`/`pwrite` consistency. (#7860)
* Documentation consistency.

* Improve consistency of `pread`/`pwrite` implementation when given length.

* Remove HAVE_PREAD / HAVE_PWRITE - it is no longer optional.
2023-05-27 18:48:47 +09:00
Peter Zhu c37ebfe08f Remove dead code in string.c
The STR_DEC_LEN macro is not used.
2023-05-26 13:34:26 -04:00
Nobuyoshi Nakada c6e4337a99
[DOC] No document under win32
Also .document was removed at 57bc4cfa28.
2023-05-27 02:07:47 +09:00
Masafumi Koba 94e5ecbbdd [ruby/rdoc] Improve `<summary>` CSS on sidebar
- Use a smaller font size for the toggle symbol. (Currently, it seems a little too large)
- Use the child combinator (`>`) to unify selectors.
- Use `margin-left` instead of whitespace within the `content` property.
- Use `::` instead of outdated `:` for the pseudo-element symbol.
  (See https://developer.mozilla.org/en-US/docs/Web/CSS/::before)

https://github.com/ruby/rdoc/commit/61ce0a7d75
2023-05-26 16:26:46 +00:00
Masafumi Koba 54b7ce0bff [ruby/rdoc] Improve layout CSS
- Use the `grid` property for the page layout.
  - https://caniuse.com/css-grid
- Adjust the `<main>` margin.
- Make the sidebar responsive and resizable.
  - https://caniuse.com/css-math-functions
  - https://caniuse.com/css-resize

Note all modern browsers support the new CSS properties and functions used by this change.

https://github.com/ruby/rdoc/commit/2db5097c41
2023-05-26 16:24:57 +00:00
Jeremy Evans 618a04d211
Document throw/catch in the control expressions document [ci skip]
This are implemented as Kernel methods and not keywords, but I
still think they are worth documenting with the other control
flow expressions.
2023-05-26 07:58:40 -07:00
Peter Zhu 4847b7ac28 T_HASH is no longer on transient heap 2023-05-26 09:24:23 -04:00
Burdette Lamar d62ae18797
[DOC] Link fix (#7862) 2023-05-26 09:20:18 -04:00
Jun Aruga 6d450d62fb testing_ruby.md: Update `make test-all` tips [ci skip] 2023-05-26 09:19:38 -04:00
git cc698c6cc2 * expand tabs. [ci skip]
Please consider using misc/expand_tabs.rb as a pre-commit hook.
2023-05-26 05:51:35 +00:00
KJ Tsanaktsidis d1628feaaf Remvoe very high timeout on test_race_gets_and_close
This test should be fixed and fast now because the closing thread sleeps
appropriately waiting for the file descriptor to be unused.
2023-05-26 14:51:23 +09:00
KJ Tsanaktsidis 66871c5a06 Fix busy-loop when waiting for file descriptors to close
When one thread is closing a file descriptor whilst another thread is
concurrently reading it, we need to wait for the reading thread to be
done with it to prevent a potential EBADF (or, worse, file descriptor
reuse).

At the moment, that is done by keeping a list of threads still using the
file descriptor in io_close_fptr. It then continually calls
rb_thread_schedule() in fptr_finalize_flush until said list is empty.

That busy-looping seems to behave rather poorly on some OS's,
particulary FreeBSD. It can cause the TestIO#test_race_gets_and_close
test to fail (even with its very long 200 second timeout) because the
closing thread starves out the using thread.

To fix that, I introduce the concept of struct rb_io_close_wait_list; a
list of threads still using a file descriptor that we want to close. We
call `rb_notify_fd_close` to let the thread scheduler know we're closing
a FD, which fills the list with threads. Then, we call
rb_notify_fd_close_wait which will block the thread until all of the
still-using threads are done.

This is implemented with a condition variable sleep, so no busy-looping
is required.
2023-05-26 14:51:23 +09:00
KJ Tsanaktsidis 54a74c4203 Move rb_thread_cond_struct definition into thread_native.h
On Win32, currently, rb_nativethread_cond_t is an incomplete type
because it's a typedef for `struct rb_thread_cond_struct`. That means
you can't actually allocate a rb_nativethread_cond_t unless you also
include THREAD_IMPL_H (since its defined in thread_win32.h)
(alternatively, including vm_core.h also works).

Move the definition of rb_thread_cond_struct into thread_native.h to
alleviate this.
2023-05-26 14:51:23 +09:00
KJ Tsanaktsidis 8c4da473de Remove excessive timeout on test_wait_exception for FreeBSD
This should now be fixed by the previous commit.
2023-05-26 14:48:08 +09:00
KJ Tsanaktsidis 8e1abef469 Fix a potential busy-loop in the thread scheduler (esp. on FreeBSD)
This patch fixes a potential busy-loop in the thread scheduler. If there
are two threads, the main thread (where Ruby signal handlers must run)
and a sleeping thread, it is possible for the following sequence of
events to occur:

* The sleeping thread is in native_sleep -> sigwait_sleep A signal
* arives, kicking this thread out of rb_sigwait_sleep The sleeping
* thread calls THREAD_BLOCKING_END and eventually
  thread_sched_to_running_common
* the sleeping thread writes into the sigwait_fd pipe by calling
  rb_thread_wakeup_timer_thread
* the sleeping thread re-loops around in native_sleep() because
  the desired sleep time has not actually yet expired
* that calls rb_sigwait_sleep again the ppoll() in rb_sigwait_sleep
* immediately returns because
  of the byte written into the sigwait_fd by
rb_thread_wakeup_timer_thread
* that wakes the thread up again and kicks the whole cycle off again.

Such a loop can only be broken by the main thread waking up and handling
the signal, such that ubf_threads_empty() below becomes true again;
however this loop can actually keep things so busy (and cause so much
contention on the main thread's interrupt_lock) that the main thread
doesn't deal with the signal for many seconds. This seems particuarly
likely on FreeBSD 13.

(the cycle can also be broken by the sleeping thread finally elapsing
its desired sleep time).

The fix for _this_ loop is to only wakeup the timer thrad in
thread_sched_to_running_common if the current thread is not itself the
sigwait thread.

An almost identical loop also happens in the same circumstances because
the call to check_signals_nogvl (through sigwait_timeout) in
rb_sigwait_sleep returns true if there is any pending signal for the
main thread to handle. That then causes rb_sigwait_sleep to skip over
sleeping entirely.

This is unnescessary and counterproductive, I believe; if the main
thread needs to be woken up that is done inline in check_signals_nogvl
anyway.

See https://bugs.ruby-lang.org/issues/19680
2023-05-26 14:48:08 +09:00
dependabot[bot] 3dae55ea2f Bump github/codeql-action from 2.3.3 to 2.3.5
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2.3.3 to 2.3.5.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](29b1f65c5e...0225834cc5)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-26 12:39:20 +09:00
Sutou Kouhei d83f32c34b [rubygems/rubygems] Load plugin immediately
We can install RubyGems plugin by "gem install XXX". The installed
plugin is used from the NEXT "gem ...".

For example, "gem install gem-src kaminari" doesn't use gem-src plugin
for kaminari. "gem install gem-src && gem install kaminari" uses
gem-src plugin for kaminari.

How about loading a plugin immediately when the plugin is installed?
If this proposal is implemented, "gem install gem-src kaminari" works
like "gem install gem-src && gem install kaminari".

https://github.com/rubygems/rubygems/commit/4917d96f4c
2023-05-25 21:51:15 +00:00
Peter Zhu e87f6c899e Don't immediately promote children of old objects
[Feature #19678]

References from an old object to a write barrier protected young object
will not immediately promote the young object. Instead, the young object
will age just like any other object, meaning that it has to survive
three collections before being promoted to the old generation.
References from an old object to a write barrier unprotected object will
place the parent object in the remember set for marking during minor
collections. This allows the child object to be reclaimed in minor
collections at the cost of increased time for minor collections.

On one of [Shopify's highest traffic Ruby apps, Storefront
Renderer](https://shopify.engineering/how-shopify-reduced-storefront-response-times-rewrite),
we saw significant improvements after deploying this feature in
production. We compare the GC time and response time of web workers that
have the original behaviour (non-experimental group) and this new
behaviour (experimental group). We see that with this feature we spend
significantly less time in the GC, 0.81x on average, 0.88x on p99, and
0.45x on p99.9.

This translates to improvements in average response time (0.96x) and p99
response time (0.92x).
2023-05-25 08:56:22 -04:00