77865 Commits

Author SHA1 Message Date
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
git
57fce84c14 Update default gems list at e5bce57e1d3ab6eb8c218355e9b31f [ci skip] 2023-05-25 09:12:20 +00:00
Hiroshi SHIBATA
e5bce57e1d [ruby/nkf] Bump up nkf-0.1.3
https://github.com/ruby/nkf/commit/bc90e2ed39
2023-05-25 09:11:36 +00:00
Hiroshi SHIBATA
3026a2f4e9 [ruby/nkf] Added mission extension configuration
https://github.com/ruby/nkf/commit/e627a39dff
2023-05-25 09:11:35 +00:00
Hiroshi SHIBATA
5ade6be777
Fixup 5bfb317a938 2023-05-25 16:09:29 +09:00
Hiroshi SHIBATA
5bfb317a93 [ruby/benchmark] Don't use version.rb
https://github.com/ruby/benchmark/commit/6d51b10500
2023-05-25 07:08:44 +00:00
git
8e2fac7b9c Update bundled gems list at 2023-05-25 2023-05-25 06:59:46 +00:00
Hiroshi SHIBATA
d1237bc3a4
Move gemspec files to top of lib directory.
They have version.rb files with same directory.
  But version.rb have been removed at https://github.com/ruby/ruby/pull/3375
  There is no reason to locate under the library name of directory.
2023-05-25 15:47:48 +09:00
dependabot[bot]
99a078f4ed Bump necojackarc/auto-request-review from 0.11.0 to 0.12.0
Bumps [necojackarc/auto-request-review](https://github.com/necojackarc/auto-request-review) from 0.11.0 to 0.12.0.
- [Release notes](https://github.com/necojackarc/auto-request-review/releases)
- [Commits](a39c70b6e7...6a51cebffe)

---
updated-dependencies:
- dependency-name: necojackarc/auto-request-review
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-25 12:42:03 +09:00
Samuel Williams
492e0025fd
Allow environment variable to control madvise advice. (#7855)
Introduce experimental support for explicitly specifying the `advice` value provided to `madvise` when releasing the fiber stack.
2023-05-25 11:17:49 +09:00
Nobuyoshi Nakada
31b28b31fa [ruby/csv] Support RJIT (https://github.com/ruby/csv/pull/281)
In Ruby 3.3, MJIT is replaced with RJIT.

https://github.com/ruby/csv/commit/cc6b47a4a7
2023-05-25 01:44:17 +09:00
Luke Gruber
38ef537ce0 [ruby/csv] test: rename Helper to CSVHelper
(https://github.com/ruby/csv/pull/278)

Rename it so that in ruby/ruby, the generic name Helper is not used.
2023-05-25 01:44:17 +09:00
Yuki Tsujimoto
e151a2ff8e [ruby/csv] docs: fix example in Recipe: Capture Unconverted Fields
(https://github.com/ruby/csv/pull/276)

I've fixed the example in `Recipe: Capture Unconverted Fields`.

https://ruby.github.io/csv/doc/csv/recipes/parsing_rdoc.html#label-Recipe-3A+Capture+Unconverted+Fields

`parsed` is wrong: header row is missing and the values should be
integers.

```
$ ruby -v
ruby 3.2.1 (2023-02-08 revision https://github.com/ruby/csv/commit/31819e82c8) [x86_64-darwin21]

$ cat unconverted_fields.rb
require "csv"

source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
parsed = CSV.parse(source, converters: :integer, unconverted_fields: true)
p parsed
parsed.each {|row| p row.unconverted_fields }

$ ruby unconverted_fields.rb
[["Name", "Value"], ["foo", 0], ["bar", 1], ["baz", 2]]
["Name", "Value"]
["foo", "0"]
["bar", "1"]
["baz", "2"]
```
2023-05-25 01:44:17 +09:00
Sutou Kouhei
88876f02c1 [ruby/csv] All Enumerable based methods consume the same lines with other methods
This may have a performance penalty. We should benchmark this.

GitHub: fix https://github.com/ruby/csv/pull/260

Reported by Lhoussaine Ghallou. Thanks!!!

https://github.com/ruby/csv/commit/acc05116c5
2023-05-25 01:44:17 +09:00
Sutou Kouhei
73c56e06c4 [ruby/csv] CSV#read consumes the same lines with other methods like CSV#shift
GitHub: fix https://github.com/ruby/csv/pull/258

Reported by Lhoussaine Ghallou. Thanks!!!

https://github.com/ruby/csv/commit/71e6d24e28
2023-05-25 01:44:17 +09:00
Mau Magnaguagno
a0709d0aae [ruby/csv] Remove no longer required refinements
(https://github.com/ruby/csv/pull/250)

Since PR #159, the minimum Ruby version is 2.5.0, a version which no
longer requires refinements for String#delete_suffix?, String#match? and
Regexp#match?.
2023-05-25 01:44:17 +09:00
Sampat Badhe
55a900d9cc [ruby/csv] Fix typos (https://github.com/ruby/csv/pull/236)
https://github.com/ruby/csv/commit/d5e401266f
2023-05-25 01:44:17 +09:00
Burdette Lamar
81c57ae7ac [ruby/csv] Small RDoc changes for recipes
(https://github.com/ruby/csv/pull/190)

https://github.com/ruby/csv/commit/2102c78384
2023-05-25 01:44:17 +09:00
Burdette Lamar
347afd39a3 [ruby/csv] Enhanced RDoc for CSV::Table
(https://github.com/ruby/csv/pull/166)

https://github.com/ruby/csv/commit/1d685aede3
2023-05-25 01:44:17 +09:00
Peter Zhu
a23ae56c4d Add REMEMBERED_WB_UNPROTECTED_OBJECTS_LIMIT_RATIO
[Feature #19571]

This commit adds the environment variable
`RUBY_GC_HEAP_REMEMBERED_WB_UNPROTECTED_OBJECTS_LIMIT_RATIO` which is
used to calculate the `remembered_wb_unprotected_objects_limit` using a
ratio of `old_objects`. This should improve performance by reducing
major GC because, in a major GC, we mark all of the old objects, so we
should have more uncollectible WB unprotected objects before starting a
major GC. The default has been set to 0.01 (1% of old objects).

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 patch in
production. In the graphs below, we have the `tuned` group which uses
`RUBY_GC_HEAP_REMEMBERED_WB_UNPROTECTED_OBJECTS_LIMIT_RATIO=0.01` (the
default value), and an `untuned` group, which turns this feature off
with `RUBY_GC_HEAP_REMEMBERED_WB_UNPROTECTED_OBJECTS_LIMIT_RATIO=0`. We
see that the tuned group spends significantly less time in GC, on
average 0.67x of the time compared to the untuned group and 0.49x for
p99. We see this improvement in GC time translate to improvements in
response times. The average response time is now 0.96x of the time
compared to the untuned group and 0.86x for p99.

https://user-images.githubusercontent.com/15860699/229559078-e23e8ce4-5f1f-4a2f-b5ef-5769f92b8c70.png
2023-05-24 12:11:48 -04:00
Samuel Williams
6d976eb534
Fix "runs a C function with the global lock unlocked and unlocks IO with the generic RUBY_UBF_IO" on Windows. (#7848)
* Enable borked spec.

* Ensure win32 wrappers are visible and used.

* Reorganise `read`/`write`/`pipe` in `thread_spec.c`.
2023-05-24 22:45:34 +09:00
Jean Boussier
85b4cd7cf8
gc.c: get rid of unused objspace parameters (#7853) 2023-05-24 15:14:46 +02:00
yui-knk
5f65e8c5d5 Rename rb_node_name to the original name
98637d421dbe8bcf86cc2effae5e26bb96a6a4da changes the name of
the function. However this function is exported as global,
then change the name to origin one for keeping compatibility.
2023-05-24 20:54:48 +09:00
Nobuyoshi Nakada
d8da563f9e
Add a newline at EOF [ci skip] 2023-05-24 15:04:07 +09:00
Nobuyoshi Nakada
1ea9bb8496
[ruby/racc] Add a newline at EOF [ci skip]
https://github.com/ruby/racc/commit/8f1dab6759
2023-05-24 15:02:49 +09:00
dependabot[bot]
a692122fcd Bump necojackarc/auto-request-review from 0.10.0 to 0.11.0
Bumps [necojackarc/auto-request-review](https://github.com/necojackarc/auto-request-review) from 0.10.0 to 0.11.0.
- [Release notes](https://github.com/necojackarc/auto-request-review/releases)
- [Commits](5f91f424ca...a39c70b6e7)

---
updated-dependencies:
- dependency-name: necojackarc/auto-request-review
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-24 12:43:17 +09:00
dependabot[bot]
6406ae6931 Bump dependabot/fetch-metadata from 1.5.0 to 1.5.1
Bumps [dependabot/fetch-metadata](https://github.com/dependabot/fetch-metadata) from 1.5.0 to 1.5.1.
- [Release notes](https://github.com/dependabot/fetch-metadata/releases)
- [Commits](28a846a119...cd6e996708)

---
updated-dependencies:
- dependency-name: dependabot/fetch-metadata
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-24 12:42:12 +09:00
Samuel Williams
135a0d26a1
Improvements to IO::Buffer read/write/pread/pwrite. (#7826)
- Fix IO::Buffer `read`/`write` to use a minimum length.
2023-05-24 10:17:35 +09:00
Ufuk Kayserilioglu
12dfd9d1c9
[flori/json] Call super in included hook
The C extension defines an `included` hook for the
`JSON::Ext::Generator::GeneratorMethods::String` module but neglects to
call `super` in the hook. This can break the functionality of various
other code that rely on the fact that `included` on `Module` will always
be called.

https://github.com/flori/json/commit/cd8bbe56a3
2023-05-24 09:37:30 +09:00
Samuel Williams
28056a6d16
Add support for pread/pwrite on windows. (#7827) 2023-05-24 09:15:20 +09:00
Peter Zhu
9592bc7039 Remove dead code in rb_hash_replace
We now always copy the ST table, so we don't need to initialize the ST
table of hash when hash2 is empty.
2023-05-23 15:27:56 -04:00
Peter Zhu
a86f798fc2 Fix crash when replacing ST hash with AR hash
With VWA, AR hashes are much larger than ST hashes. Hash#replace
attempts to directly copy the contents of AR hashes into ST hashes so
there will be memory corruption caused by writing past the end of memory.

This commit changes it so that if a ST hash is being replaced with an AR
hash it will insert each element into the ST hash.
2023-05-23 15:27:56 -04:00
Jenny Shen
061e01ee50 [rubygems/rubygems] Remove forward slash in key regardless if it contains __
https://github.com/rubygems/rubygems/commit/33a02eec00
2023-05-23 18:37:09 +00:00
Jenny Shen
e854b050cc [rubygems/rubygems] Modify invalid key check to accept keys with colons
https://github.com/rubygems/rubygems/commit/413033198b

Co-authored-by: Eric Herscovich <eric.herscovich@shopify.com>
2023-05-23 18:37:08 +00:00
TSUYUSATO Kitsune
92d6c9a7b1 [ruby/irb] Allow show_source for private methods
(https://github.com/ruby/irb/pull/589)

* Allow `show_source` for private methods

Fix https://github.com/ruby/irb/pull/577

* Pend tests on TruffleRuby

It seems `eval(..., __LINE__ + 1)` does not work.
Other similar tests are also pended on TruffleRuby, so I think it
is acceptable.

* Use `private_method_defined?` instead of `defined?`
2023-05-23 16:16:37 +00:00
Peter Zhu
24a6609ccb Remove dead code in ar_copy
new_tab can no longer ever be NULL so this is dead code.
2023-05-23 11:11:23 -04:00