91977 Commits

Author SHA1 Message Date
John Hawthorn
e596cf6e93 Make FrozenCore a plain T_CLASS 2025-06-02 14:57:48 -04:00
Jean Boussier
db2cfebff1 Pin shape->edges 2025-06-02 17:49:53 +02:00
Jean Boussier
e9fd44dd72 shape.c: Implement a lock-free version of get_next_shape_internal
Whenever we run into an inline cache miss when we try to set
an ivar, we may need to take the global lock, just to be able to
lookup inside `shape->edges`.

To solve that, when we're in multi-ractor mode, we can treat
the `shape->edges` as immutable. When we need to add a new
edge, we first copy the table, and then replace it with
CAS.

This increases memory allocations, however we expect that
creating new transitions becomes increasingly rare over time.

```ruby
class A
  def initialize(bool)
    @a = 1
    if bool
      @b = 2
    else
      @c = 3
    end
  end

  def test
    @d = 4
  end
end

def bench(iterations)
  i = iterations
  while i > 0
    A.new(true).test
    A.new(false).test
    i -= 1
  end
end

if ARGV.first == "ractor"
  ractors = 8.times.map do
    Ractor.new do
      bench(20_000_000 / 8)
    end
  end
  ractors.each(&:take)
else
  bench(20_000_000)
end
```

The above benchmark takes 27 seconds in Ractor mode on Ruby 3.4,
and only 1.7s with this branch.

Co-Authored-By: Étienne Barrié <etienne.barrie@gmail.com>
2025-06-02 17:49:53 +02:00
Peter Zhu
cbd49ecbbe Remove unused RBASIC_RESET_FLAGS 2025-06-02 09:52:25 -04:00
Peter Zhu
acc273a8a4 Remove dependancy of default.c on internal/object.h
We don't want the default GC to depend on Ruby internals so we can build
it as a modular GC.
2025-06-02 09:52:25 -04:00
Nobuyoshi Nakada
cfe17520ba
[DOC] Mention vsdevcmd.bat 2025-06-02 22:08:32 +09:00
Jean Boussier
ff222ac27a compile.c: Handle anonymous variables in outer_variable_cmp
[Bug #21370]
2025-06-02 13:41:28 +02:00
Samuel Williams
9a29252830
Fix compatibility with fiber schedulers that don't implement #fiber_interrupt. (#13492) 2025-06-02 18:50:23 +09:00
Hiroshi SHIBATA
20d7db8cba
Handle test failure of mock object
Fixup 4c26a38ed3c

https://rubyci.s3.amazonaws.com/amazon2/ruby-master/log/20250601T213003Z.fail.html.gz

```
1)
An exception occurred during: Mock.verify_count
File.birthtime accepts an object that has a #to_path method FAILED
Mock 'path' expected to receive to_path(:any_args) exactly 1 times
but received it 0 times
/home/chkbuild/chkbuild/tmp/build/20250601T213003Z/ruby/spec/ruby/core/file/birthtime_spec.rb:4:in 'block in <top (required)>'
/home/chkbuild/chkbuild/tmp/build/20250601T213003Z/ruby/spec/ruby/core/file/birthtime_spec.rb:3:in '<top (required)>'
```
2025-06-02 08:50:54 +09:00
git
3fd2d54a0a Update bundled gems list as of 2025-06-01 2025-06-01 07:03:33 +00:00
Nobuyoshi Nakada
4c26a38ed3
Skip birthtime failures on old linux
`statx(2)` is available since Linux 4.11 and glibc 2.28.
2025-06-01 14:22:51 +09:00
Nobuyoshi Nakada
1395abd025
Win: Use VsDevCmd.bat instead of old vcvarsall.bat 2025-06-01 12:16:18 +09:00
Nobuyoshi Nakada
a64616fb4c
Win: Fix winget command to install 2025-06-01 10:24:06 +09:00
Nobuyoshi Nakada
63617a6ce1
Update rake version in bundler tests 2025-05-31 20:56:00 +09:00
Nobuyoshi Nakada
f2ddd923ed
Update rake version in lock files 2025-05-31 19:21:14 +09:00
git
32c708efbd Update bundled gems list as of 2025-05-31 2025-05-31 09:43:52 +00:00
tomoya ishida
49f35c917b
Bump bundled bigdecimal to 3.2.1 (#13482) 2025-05-31 09:31:17 +00:00
Daisuke Aritomo
2097d3794d Fix typo (s/ractore/ractor/) 2025-05-31 18:31:10 +09:00
Koichi Sasada
7b75b1f2da prepare IDs for Ractor::monitor
To prevent the following strange error, prepare IDs at first.

```
     <internal:ractor>:596:in 'Ractor#monitor': symbol :exited is already registered with 98610c (fatal)
             from <internal:ractor>:550:in 'Ractor#join'
             from <internal:ractor>:574:in 'Ractor#value'
             from bootstraptest.test_ractor.rb_2013_1309.rb:12:in '<main>'
```

BTW, the error should be fixed on ID management system.
2025-05-31 18:29:02 +09:00
Koichi Sasada
e8b31c273c rake 13.3.0 -> 13.2.1
`make test-bundler-parallel` prints many errors, so try to
downgrade rake version.

```
  219) bundle install --standalone run in a subdirectory with --binstubs creates stubs that can be symlinked
       Failure/Error:
               raise <<~ERROR
                 #{error_header}

                 ----------------------------------------------------------------------
                 #{stdboth}
                 ----------------------------------------------------------------------
               ERROR

       RuntimeError:

         Commands:
         $ /home/ko1/ruby/build/trunk/ruby -I/home/ko1/ruby/src/trunk/spec/bundler -r/home/ko1/ruby/src/trunk/spec/bundler/support/artifice/compact_index.rb -r/home/ko1/ruby/src/trunk/spec/bundler/support/hax.rb /home/ko1/ruby/src/trunk/tmp/2.13/gems/system/bin/bundle config set --local path /home/ko1/ruby/src/trunk/tmp/2.13/bundled_app/bundle
         # $? => 0
         Invoking `/home/ko1/ruby/build/trunk/ruby -I/home/ko1/ruby/src/trunk/spec/bundler -r/home/ko1/ruby/src/trunk/spec/bundler/support/artifice/compact_index.rb -r/home/ko1/ruby/src/trunk/spec/bundler/support/hax.rb /home/ko1/ruby/src/trunk/tmp/2.13/gems/system/bin/bundle install --standalone --binstubs` failed with output:

         ----------------------------------------------------------------------
         [DEPRECATED] The --binstubs option will be removed in favor of `bundle binstubs --all`
         Could not find compatible versions

         Because every version of rails depends on rake = 13.3.0
           and rake = 13.3.0 could not be found in rubygems repository https://gem.repo1/ or installed locally,
           rails cannot be used.
         So, because Gemfile depends on rails >= 0,
           version solving has failed.
         Fetching gem metadata from https://gem.repo1/...
         Resolving dependencies...
         ----------------------------------------------------------------------
       Shared Example Group: "bundle install --standalone" called from ./spec/bundler/install/gems/standalone_spec.rb:532
       # /home/ko1/ruby/src/trunk/spec/bundler/support/command_execution.rb:26:in 'Spec::CommandExecution#raise_error!'
       # /home/ko1/ruby/src/trunk/spec/bundler/support/subprocess.rb:66:in 'Spec::Subprocess#sh'
       # /home/ko1/ruby/src/trunk/spec/bundler/support/helpers.rb:216:in 'Spec::Helpers#sys_exec'
       # /home/ko1/ruby/src/trunk/spec/bundler/support/helpers.rb:107:in 'Spec::Helpers#bundle'
       # /home/ko1/ruby/src/trunk/spec/bundler/install/gems/standalone_spec.rb:482:in 'block (3 levels) in <top (required)>'
       # /home/ko1/ruby/src/trunk/spec/bundler/spec_helper.rb:107:in 'block (4 levels) in <top (required)>'
       # /home/ko1/ruby/src/trunk/spec/bundler/spec_helper.rb:107:in 'block (3 levels) in <top (required)>'
       # /home/ko1/ruby/src/trunk/spec/bundler/support/helpers.rb:355:in 'block in Spec::Helpers#with_gem_path_as'
       # /home/ko1/ruby/src/trunk/spec/bundler/support/helpers.rb:369:in 'Spec::Helpers#without_env_side_effects'
       # /home/ko1/ruby/src/trunk/spec/bundler/support/helpers.rb:350:in 'Spec::Helpers#with_gem_path_as'
       # /home/ko1/ruby/src/trunk/spec/bundler/spec_helper.rb:106:in 'block (2 levels) in <top (required)>'
```
2025-05-31 17:15:44 +09:00
Nobuyoshi Nakada
9dc9d5f5a6
[DOC] Fix indentation
RDoc markdown parser requires exact 4 spaces or tab as indentation.
Also the first nested bullet list must be separated from the enclosing
bullet list item by a blank line.
2025-05-31 16:49:21 +09:00
Koichi Sasada
57d10c6e80 NEWS entries for Ractor::Port 2025-05-31 13:06:22 +09:00
Koichi Sasada
c0c94ab183 skip failing test in a week
```
  1) Failure:
TestGc#test_gc_stress_at_startup [/home/chkbuild/chkbuild/tmp/build/20250530T213003Z/ruby/test/ruby/test_gc.rb:799]:
[Bug #15784]
pid 1748790 killed by SIGSEGV (signal 11) (core dumped).

1. [3/3] Assertion for "success?"
   | Expected #<Process::Status: pid 1748790 SIGSEGV (signal 11) (core dumped)> to be success?.
```
2025-05-31 13:05:16 +09:00
Koichi Sasada
7924296844 skip flaky test
```
  1) Failure:
TestProcess#test_warmup_frees_pages [/tmp/ruby/src/trunk-random1/test/ruby/test_process.rb:2772]:
<164348> expected but was
<165985>.
```

can someone investigate it?
2025-05-31 08:17:36 +09:00
git
e577edb12e Update bundled gems list as of 2025-05-30 2025-05-30 19:14:14 +00:00
Koichi Sasada
49b7a092fa skip tests for BigDecimal 3.2.0 2025-05-31 04:01:33 +09:00
Koichi Sasada
7013174185 fix for test-bundled-gems to catch up new API 2025-05-31 04:01:33 +09:00
Koichi Sasada
ef2bb61018 Ractor::Port
* Added `Ractor::Port`
  * `Ractor::Port#receive` (support multi-threads)
  * `Rcator::Port#close`
  * `Ractor::Port#closed?`
* Added some methods
  * `Ractor#join`
  * `Ractor#value`
  * `Ractor#monitor`
  * `Ractor#unmonitor`
* Removed some methods
  * `Ractor#take`
  * `Ractor.yield`
* Change the spec
  * `Racotr.select`

You can wait for multiple sequences of messages with `Ractor::Port`.

```ruby
ports = 3.times.map{ Ractor::Port.new }
ports.map.with_index do |port, ri|
  Ractor.new port,ri do |port, ri|
    3.times{|i| port << "r#{ri}-#{i}"}
  end
end

p ports.each{|port| pp 3.times.map{port.receive}}

```

In this example, we use 3 ports, and 3 Ractors send messages to them respectively.
We can receive a series of messages from each port.

You can use `Ractor#value` to get the last value of a Ractor's block:

```ruby
result = Ractor.new do
  heavy_task()
end.value
```

You can wait for the termination of a Ractor with `Ractor#join` like this:

```ruby
Ractor.new do
  some_task()
end.join
```

`#value` and `#join` are similar to `Thread#value` and `Thread#join`.

To implement `#join`, `Ractor#monitor` (and `Ractor#unmonitor`) is introduced.

This commit changes `Ractor.select()` method.
It now only accepts ports or Ractors, and returns when a port receives a message or a Ractor terminates.

We removes `Ractor.yield` and `Ractor#take` because:
* `Ractor::Port` supports most of similar use cases in a simpler manner.
* Removing them significantly simplifies the code.

We also change the internal thread scheduler code (thread_pthread.c):
* During barrier synchronization, we keep the `ractor_sched` lock to avoid deadlocks.
  This lock is released by `rb_ractor_sched_barrier_end()`
  which is called at the end of operations that require the barrier.
* fix potential deadlock issues by checking interrupts just before setting UBF.

https://bugs.ruby-lang.org/issues/21262
2025-05-31 04:01:33 +09:00
Kunshan Wang
d2a1ad00cb [ruby/mmtk] Fix environment variable parsing
Ues more idiomatic rust approaches.

https://github.com/ruby/mmtk/commit/ef125f9eae
2025-05-30 14:55:42 +00:00
Kunshan Wang
94688bdc7d [ruby/mmtk] Fix clippy warnings and formatting.
We also enable `#![warn(unsafe_op_in_unsafe_fn)]` in the whole mmtk_ruby
crate.

https://github.com/ruby/mmtk/commit/8b8025f71a
2025-05-30 14:55:42 +00:00
Kunshan Wang
d8774ec98f [ruby/mmtk] Bump MMTk and dependencies version
https://github.com/ruby/mmtk/commit/de252637ec
2025-05-30 14:55:41 +00:00
Kunshan Wang
60de513d05 [ruby/mmtk] Remove unused constant
Remove the unused constant HAS_MOVED_GFIELDSTBL and related methods.

In the mmtk/mmtk-ruby repo, we are now able to find the global field
(IV) table of a moved object during copying GC without using the
HAS_MOVED_GFIELDSTBL bit.  We synchronize some of the code, although we
haven't implemented moving GC in ruby/mmtk, yet.

See: 13080acdf5

https://github.com/ruby/mmtk/commit/400ba4e747
2025-05-30 14:55:41 +00:00
Tavian Barnes
f8db23afe5
ZJIT: Fold more fixnum operations (#13465) 2025-05-30 10:27:00 -04:00
Max Bernstein
65e9791c55
ZJIT: Assert that we're compiling a specific YARV insn to HIR (#13471) 2025-05-30 10:23:26 -04:00
Nobuyoshi Nakada
8872d3e10b
[Feature #21205] Fix up birthtime in ruby/spec 2025-05-30 20:55:12 +09:00
Nobuyoshi Nakada
18a036a613
[Feature #21205] Define File::Stat#birthtime by statx 2025-05-30 20:55:12 +09:00
Nobuyoshi Nakada
a333fb1ecc
Win: Add scripts to install and setup 2025-05-30 18:44:28 +09:00
Peter Zhu
9f91f3617b Fix memory leak with invalid yield in prism
[Bug #21383]

The following script leaks memory:

    10.times do
      20_000.times do
        eval("class C; yield; end")
      rescue SyntaxError
      end

      puts `ps -o rss= -p #{$$}`
    end

Before:

    16464
    25536
    29424
    35904
    39552
    44576
    46736
    51600
    56096
    59824

After:

    13488
    16160
    18240
    20528
    19760
    21808
    21680
    22272
    22064
    22336
2025-05-29 16:06:49 -04:00
John Hawthorn
6a62a46c3c Read {max_iv,variation}_count from prime classext
MAX_IV_COUNT is a hint which determines the size of variable width
allocation we should use for a given class. We don't need to scope this
by namespace, if we end up with larger builtin objects on some
namespaces that isn't a user-visible problem, just extra memory use.

Similarly variation_count is used to track if a given object has had too
many branches in shapes it has used, and to use too_complex when that
happens. That's also just a hint, so we can use the same value across
namespaces without it being visible to users.

Previously variation_count was being incremented (written to) on the
RCLASS_EXT_READABLE ext, which seems incorrect if we wanted it to be
different across namespaces
2025-05-29 16:02:07 -04:00
Luke Gruber
5b3f1c4c51 Take VM lock around manipulation of fiber pool for vacant stacks
When creating fibers in multiple ractors at the same time there were
issues with the manipulation of this structure, causing segfaults.

I didn't add any tests for this because I'm making a more general
PR in the very near future to be able to run test methods (test-all suite)
inside multiple ractors at the same time. This is how this bug was
caught, running test/ruby/test_fiber.rb inside 10 ractors at once.
2025-05-29 12:51:43 -04:00
Peter Zhu
38ecaca155 [ruby/mmtk] Remove dependance on internal/object.h
https://github.com/ruby/mmtk/commit/fdc13963f0
2025-05-29 14:46:49 +00:00
Hiroshi SHIBATA
9542e3db1c
Removed needless components of BuildTools 2025-05-29 17:52:58 +09:00
Nobuyoshi Nakada
857b1ae786 [ruby/prism] [DOC] No RDoc in include/prism/ast.h
https://github.com/ruby/prism/commit/1cae6e3b02
2025-05-29 04:46:00 +00:00
Nobuyoshi Nakada
8aa21634d8 [ruby/prism] [DOC] Simply use String#ljust
https://github.com/ruby/prism/commit/ba019ab4b4
2025-05-29 04:45:59 +00:00
Nobuyoshi Nakada
5e64d5c7d9 [ruby/prism] [DOC] Markup __FILE__ as code, not emphasis
https://github.com/ruby/prism/commit/571ba378f5
2025-05-29 04:45:59 +00:00
Nobuyoshi Nakada
82c74e4282 [ruby/prism] [DOC] Stop rdoc from processing non-rdoc comments
https://github.com/ruby/prism/commit/de1faa1680
2025-05-29 04:45:59 +00:00
Nobuyoshi Nakada
22451f370e [ruby/prism] [DOC] Add code fences
https://github.com/ruby/prism/commit/641775e5fe
2025-05-29 04:45:58 +00:00
Nobuyoshi Nakada
991cf2dd4d [ruby/prism] [DOC] Specify markdown mode to RDoc
https://github.com/ruby/prism/commit/12af4e144e
2025-05-29 04:45:58 +00:00
Hiroshi SHIBATA
6256c52667
Added VS2022 BuildTools instructions 2025-05-29 13:15:12 +09:00
Hiroshi SHIBATA
5131d5ef83
VS2022 17.13.x and winsdk-10.0.26100 issues are resolved now 2025-05-29 13:15:12 +09:00