summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2025-12-26[ruby/stringio] [DOC] Doc for StringIO#preadBurdette Lamar
(https://github.com/ruby/stringio/pull/195) Previous doc unhelpfully pointed to `IO#pread`; this PR documents locally, with StringIO examples. https://github.com/ruby/stringio/commit/806f3d9741
2025-12-26[ruby/stringio] Development of 3.2.1 started.Sutou Kouhei
https://github.com/ruby/stringio/commit/c9cd1c9947
2025-12-26[ruby/mmtk] Fix cargo fmtPeter Zhu
https://github.com/ruby/mmtk/commit/f4c46cabc7
2025-12-26Update default gems list at a06a59e3b34cd5227363dc3af14dc6 [ci skip]git
2025-12-26Rename and enabled auto-update bundled gems againHiroshi SHIBATA
2025-12-26Enabled auto-update NEWS.md and sync for default gems againHiroshi SHIBATA
2025-12-26Development of 4.1.0 started.Yukihiro "Matz" Matsumoto
2025-12-26[DOC] Flush NEWS.mdYukihiro "Matz" Matsumoto
2025-12-25Update zjit bindingsPeter Zhu
2025-12-25Implement cont using declare weak referencesPeter Zhu
2025-12-25Implement weak references on gen fields cachePeter Zhu
2025-12-25Implement callcache using declare weak referencesPeter Zhu
2025-12-25Implement declarative weak references in MMTkPeter Zhu
2025-12-25Implement WeakMap and WeakKeyMap using declare weak referencesPeter Zhu
2025-12-25Implement declaring weak referencesPeter Zhu
[Feature #21084] # Summary The current way of marking weak references uses `rb_gc_mark_weak(VALUE *ptr)`. This presents challenges because Ruby's GC is incremental, meaning that if the `ptr` changes (e.g. realloc'd or free'd), then we could have an invalid memory access. This also overwrites `*ptr = Qundef` if `*ptr` is dead, which prevents any cleanup to be run (e.g. freeing memory or deleting entries from hash tables). This ticket proposes `rb_gc_declare_weak_references` which declares that an object has weak references and calls a cleanup function after marking, allowing the object to clean up any memory for dead objects. # Introduction In [[Feature #19783]](https://bugs.ruby-lang.org/issues/19783), I introduced an API allowing objects to mark weak references, the function signature looks like this: ```c void rb_gc_mark_weak(VALUE *ptr); ``` `rb_gc_mark_weak` is called during the marking phase of the GC to specify that the memory at `ptr` holds a pointer to a Ruby object that is weakly referenced. `rb_gc_mark_weak` appends this pointer to a list that is processed after the marking phase of the GC. If the object at `*ptr` is no longer alive, then it overwrites the object reference with a special value (`*ptr = Qundef`). However, this API resulted in two challenges: 1. Ruby's default GC is incremental, which means that the GC is not ran in one phase, but rather split into chunks of work that interleaves with Ruby execution. The `ptr` passed into `rb_gc_mark_weak` could be on the malloc heap, and that memory could be realloc'd or even free'd. We had to use workarounds such as `rb_gc_remove_weak` to ensure that there were no illegal memory accesses. This made `rb_gc_mark_weak` difficult to use, impacted runtime performance, and increased memory usage. 2. When an object dies, `rb_gc_mark_weak` only overwites the reference with `Qundef`. This means that if we want to do any cleanup (e.g. free a piece of memory or delete a hash table entry), we could not do that and had to defer this process elsewhere (e.g. during marking or runtime). In this ticket, I'm proposing a new API for weak references. Instead of an object marking its weak references during the marking phase, the object declares that it has weak references using the `rb_gc_declare_weak_references` function. This declaration occurs during runtime (e.g. after the object has been created) rather than during GC. After an object declares that it has weak references, it will have its callback function called after marking as long as that object is alive. This callback function can then call a special function `rb_gc_handle_weak_references_alive_p` to determine whether its references are alive. This will allow the callback function to do whatever it wants on the object, allowing it to perform any cleanup work it needs. This significantly simplifies the code for `ObjectSpace::WeakMap` and `ObjectSpace::WeakKeyMap` because it no longer needs to have the workarounds for the limitations of `rb_gc_mark_weak`. # Performance The performance results below demonstrate that `ObjectSpace::WeakMap#[]=` is now about 60% faster because the implementation has been simplified and the number of allocations has been reduced. We can see that there is not a significant impact on the performance of `ObjectSpace::WeakMap#[]`. Base: ``` ObjectSpace::WeakMap#[]= 4.620M (± 6.4%) i/s (216.44 ns/i) - 23.342M in 5.072149s ObjectSpace::WeakMap#[] 30.967M (± 1.9%) i/s (32.29 ns/i) - 154.998M in 5.007157s ``` Branch: ``` ObjectSpace::WeakMap#[]= 7.336M (± 2.8%) i/s (136.31 ns/i) - 36.755M in 5.013983s ObjectSpace::WeakMap#[] 30.902M (± 5.4%) i/s (32.36 ns/i) - 155.901M in 5.064060s ``` Code: ``` require "bundler/inline" gemfile do source "https://rubygems.org" gem "benchmark-ips" end wmap = ObjectSpace::WeakMap.new key = Object.new val = Object.new wmap[key] = val Benchmark.ips do |x| x.report("ObjectSpace::WeakMap#[]=") do |times| i = 0 while i < times wmap[Object.new] = Object.new i += 1 end end x.report("ObjectSpace::WeakMap#[]") do |times| i = 0 while i < times wmap[key] wmap[val] # does not exist i += 1 end end end ``` # Alternative designs Currently, `rb_gc_declare_weak_references` is designed to be an internal-only API. This allows us to assume the object types that call `rb_gc_declare_weak_references`. In the future, if we want to open up this API to third parties, we may want to change this function to something like: ```c void rb_gc_add_cleaner(VALUE obj, void (*callback)(VALUE obj)); ``` This will allow the third party to implement a custom `callback` that gets called after the marking phase of GC to clean up any dead references. I chose not to implement this design because it is less efficient as we would need to store a mapping from `obj` to `callback`, which requires extra memory.
2025-12-25Implement rb_darray_swap_removePeter Zhu
2025-12-25test_box: avoid failure with --program-suffix (#15734)Sorah Fukumori
2025-12-25fix the condition of www repoNARUSE, Yui
2025-12-25[DOC] Escape capitalized word "data" not to be linked unexpectedlyNobuyoshi Nakada
2025-12-25[DOC] Reword "Regular Expression" to "Matched Data"Nobuyoshi Nakada
`$~` and its accessors are related to regular expressions, but are not themselves.
2025-12-25Revert "Rollback to minitest-5.27.0"Hiroshi SHIBATA
This reverts commit 8d097bc472fc66221dee23bb8f9e0dddac16db23.
2025-12-25[DOC] Add back Rust 1.85.0 requirement to NEWS.md (#15728)Godfrey Chan
* [DOC] Add back Rust 1.85.0 requirement to NEWS.md Addresses k0kubun's review in https://github.com/ruby/ruby/pull/15711#issuecomment-3690541074 NEWS.md serves both CRuby developers as well as end-users. As the release date closes in, it probably gets seen by more users than core developers (on the blog for example). Most users probably don't build Ruby by hand, and instead that is abstracted through tools like ruby-install or a package manager. For some users these tools may install pre-built binaries where they exist, in which case the Rust requirement doesn't apply. In other instances, the tools merely automate the build, in which case the correct rustc version is required to enable support. It is also a little confusing to talk about "enabling support for the JIT during the build" vs "enabling the JIT at runtime". This copy attempts to balance all of the above and hopefully gets the correct points across all intended audiences. * Apply suggestion from k0kubun Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com> --------- Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com>
2025-12-24ZJIT: Don't mark control-flow opcodes as invalidating locals (#15694)Max Bernstein
jump, branchif, etc don't invalidate locals in the JIT; they might in the interpreter because they can execute arbitrary code, but the JIT side exits before that happens.
2025-12-25Rollback to minitest-5.27.0Hiroshi SHIBATA
Test of 6.0.0 is not working with 4.0.0 stable version. https://github.com/ruby/actions/actions/runs/20488398805/job/58875672023#step:20:362 ``` rake aborted! NoMethodError: undefined method 'cov_filter=' for #<Hoe:0x00007fdb550fc840> (NoMethodError) self.cov_filter = %w[ tmp ] ^^^^^^^^^^^^^ /home/runner/work/actions/actions/ruby-4.0.0/gems/src/minitest/Rakefile:20:in 'block in <top (required)>' /home/runner/work/actions/actions/ruby-4.0.0/.bundle/gems/hoe-3.20.0/lib/hoe.rb:394:in 'BasicObject#instance_eval' /home/runner/work/actions/actions/ruby-4.0.0/.bundle/gems/hoe-3.20.0/lib/hoe.rb:394:in 'Hoe.spec' /home/runner/work/actions/actions/ruby-4.0.0/gems/src/minitest/Rakefile:11:in '<top (required)>' /home/runner/work/actions/actions/ruby-4.0.0/.bundle/gems/rake-13.3.1/exe/rake:27:in '<top (required)>' (See full trace by running task with --trace) ```
2025-12-25Revert "Rollback to test-unit 3.7.3"Hiroshi SHIBATA
This reverts commit c17307ac22f37f74786a4f016121c6ee8cc38915.
2025-12-25rbs_skip_tests_windowsSoutaro Matsumoto
2025-12-25Skip test to avoid NoMemoryErrorSoutaro Matsumoto
2025-12-25Bundle test-unit 3.7.5Soutaro Matsumoto
2025-12-25Bump RDoc to 7.0.3Stan Lo
2025-12-24Remove extra helpNARUSE, Yui
2025-12-24Reapply "Extract `ruby_api_version_name`"NARUSE, Yui
This reverts commit ba2f6972193cdbd7c1e77e26212513e47926b115. Box already used ruby_api_version_name.
2025-12-24Revert "Add link to Ruby options doc in help text"NARUSE, Yui
This reverts commit 31ff07ed1eb05d01f7da3c017d542137a3db1e94. * Don't add a test which only runs on production release * https://github.com/ruby/actions/actions/runs/20486784889/job/58870959976 * Don't add a new line to `ruby --help` * https://github.com/ruby/ruby/pull/14142#issuecomment-3689829564
2025-12-24Revert "Extract `ruby_api_version_name`"NARUSE, Yui
This reverts commit 9b576cd6255aba97e5e2f55f4b09f00c7dd0e839.
2025-12-24Fix a fragile testNobuyoshi Nakada
`Dir.mktmpdir` concatenates a random base-36 number separated by "-", so may generate pathnames containing "-j2".
2025-12-24Prevent "warning: assigned but unused variable - it"Yusuke Endoh
2025-12-24Remove unintentional returnYusuke Endoh
2025-12-24ext/-test-/scheduler/scheduler.c: explicitly ignore the result of writeYusuke Endoh
``` scheduler.c:44:5: warning: ignoring return value of ‘write’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 44 | write(blocking_state->notify_descriptor, "x", 1); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ```
2025-12-24Win32: Remove an unused functionNobuyoshi Nakada
Since 50e5c542cc0541fb38e52766d88d87bd8a96b072, `constat_reset` is no longer used.
2025-12-24Rollback to test-unit 3.7.3Hiroshi SHIBATA
3.7.5 is not working with rbs-3.10.0 https://github.com/ruby/ruby/actions/runs/20480628393/job/58853288287#step:22:353 ``` D:/a/ruby/ruby/src/.bundle/gems/test-unit-3.7.5/lib/test/unit/testcase.rb:641:in 'block (2 levels) in Test::Unit::TestCase#run': failed to allocate memory (NoMemoryError) ```
2025-12-24Disable auto-update of bundled gemsHiroshi SHIBATA
2025-12-24Restore gem updates that are accidentally deletedHiroshi SHIBATA
2025-12-24Added release histories of default/bundled gems from Ruby 3.4.8Hiroshi SHIBATA
2025-12-24Update to test-unit 3.7.5 at NEWS.mdHiroshi SHIBATA
2025-12-24Added https://github.com/ruby/net-http/issues/205 to NEWS.mdHiroshi SHIBATA
2025-12-24Update bundled gems list as of 2025-12-24git
2025-12-24[DOC] Update ZJIT status in NEWS.mdGodfrey Chan
As for Ruby v4.0.0-preview3, ZJIT support is enabled by default on supported platforms. The previous phrasing is not relevant for most users. Replaced with brief instructions for enabling the JIT itself.
2025-12-24Box: show the fully qualified URL of the Ruby::Box docSatoshi Tagomori
2025-12-24Remove an extra dot from `RUBY_API_VERSION_STR`Nobuyoshi Nakada
2025-12-24Lrama v0.7.1yui-knk
2025-12-24Fix a possible memory leak in dtoaNobuyoshi Nakada
Fix GH-15061