<feed xmlns='http://www.w3.org/2005/Atom'>
<title>ruby.git/thread_sync.c, branch v3_4_9</title>
<subtitle>The Ruby Programming Language</subtitle>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/'/>
<entry>
<title>Reapply "merge revision(s) 62430c19c9f1ab49429cebe65f30588472648c95: [Backport #21342]"</title>
<updated>2025-09-29T22:10:58+00:00</updated>
<author>
<name>Takashi Kokubun</name>
<email>takashikkbn@gmail.com</email>
</author>
<published>2025-09-29T22:10:37+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=264b2d78c366491834c9ce4499a4ad7b7564b89d'/>
<id>264b2d78c366491834c9ce4499a4ad7b7564b89d</id>
<content type='text'>
This reverts commit c414b9871f263331cde0af1c08cf5c1a47e1aedf.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This reverts commit c414b9871f263331cde0af1c08cf5c1a47e1aedf.
</pre>
</div>
</content>
</entry>
<entry>
<title>Revert "merge revision(s) 62430c19c9f1ab49429cebe65f30588472648c95: [Backport #21342]"</title>
<updated>2025-09-29T22:08:47+00:00</updated>
<author>
<name>Takashi Kokubun</name>
<email>takashikkbn@gmail.com</email>
</author>
<published>2025-09-29T22:08:47+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=c414b9871f263331cde0af1c08cf5c1a47e1aedf'/>
<id>c414b9871f263331cde0af1c08cf5c1a47e1aedf</id>
<content type='text'>
This reverts commit 4306c9048fb674d24b92dc46b6746a4749564147.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This reverts commit 4306c9048fb674d24b92dc46b6746a4749564147.
</pre>
</div>
</content>
</entry>
<entry>
<title>merge revision(s) 62430c19c9f1ab49429cebe65f30588472648c95: [Backport #21342]</title>
<updated>2025-09-29T21:35:15+00:00</updated>
<author>
<name>Takashi Kokubun</name>
<email>takashikkbn@gmail.com</email>
</author>
<published>2025-09-29T21:35:15+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=4306c9048fb674d24b92dc46b6746a4749564147'/>
<id>4306c9048fb674d24b92dc46b6746a4749564147</id>
<content type='text'>
	Properly unlock locked mutexes on thread cleanup.

	Mutexes were being improperly unlocked on thread cleanup. This bug was
	introduced in 050a8954395.

	We must keep a reference from the mutex to the thread, because if the fiber
	is collected before the mutex is, then we cannot unlink it from the thread in
	`mutex_free`. If it's not unlinked from the the thread when it's freed, it
	causes bugs in `rb_thread_unlock_all_locking_mutexes`.

	We now mark the fiber when a mutex is locked, and the thread is marked
	as well. However, a fiber can still be freed in the same GC cycle as the
	mutex, so the reference to the thread is still needed.

	The reason we need to mark the fiber is that `mutex_owned_p()` has an ABA
	issue where if the fiber is collected while it's locked, a new fiber could be
	allocated at the same memory address and we could get false positives.

	Fixes [Bug #21342]

	Co-authored-by: John Hawthorn &lt;john@hawthorn.email&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
	Properly unlock locked mutexes on thread cleanup.

	Mutexes were being improperly unlocked on thread cleanup. This bug was
	introduced in 050a8954395.

	We must keep a reference from the mutex to the thread, because if the fiber
	is collected before the mutex is, then we cannot unlink it from the thread in
	`mutex_free`. If it's not unlinked from the the thread when it's freed, it
	causes bugs in `rb_thread_unlock_all_locking_mutexes`.

	We now mark the fiber when a mutex is locked, and the thread is marked
	as well. However, a fiber can still be freed in the same GC cycle as the
	mutex, so the reference to the thread is still needed.

	The reason we need to mark the fiber is that `mutex_owned_p()` has an ABA
	issue where if the fiber is collected while it's locked, a new fiber could be
	allocated at the same memory address and we could get false positives.

	Fixes [Bug #21342]

	Co-authored-by: John Hawthorn &lt;john@hawthorn.email&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Ensure fiber scheduler re-acquires mutex when interrupted from sleep. (#12158)</title>
<updated>2024-11-23T23:54:12+00:00</updated>
<author>
<name>Samuel Williams</name>
<email>samuel.williams@oriontransfer.co.nz</email>
</author>
<published>2024-11-23T23:54:12+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=a8c2d5e7bee5fad0965baeb58d312ddc5932ec26'/>
<id>a8c2d5e7bee5fad0965baeb58d312ddc5932ec26</id>
<content type='text'>
[Bug #20907]</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[Bug #20907]</pre>
</div>
</content>
</entry>
<entry>
<title>Replace assert with RUBY_ASSERT in thread_sync.c</title>
<updated>2024-02-12T20:07:47+00:00</updated>
<author>
<name>Peter Zhu</name>
<email>peter@peterzhu.ca</email>
</author>
<published>2024-02-08T14:45:28+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=80700f453e8ca13925790bd980197dc302696c0a'/>
<id>80700f453e8ca13925790bd980197dc302696c0a</id>
<content type='text'>
assert does not print the bug report, only the file and line number of
the assertion that failed. RUBY_ASSERT prints the full bug report, which
makes it much easier to debug.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
assert does not print the bug report, only the file and line number of
the assertion that failed. RUBY_ASSERT prints the full bug report, which
makes it much easier to debug.
</pre>
</div>
</content>
</entry>
<entry>
<title>Remove SizedQueue#freeze</title>
<updated>2024-01-17T21:17:25+00:00</updated>
<author>
<name>Jeremy Evans</name>
<email>code@jeremyevans.net</email>
</author>
<published>2024-01-17T19:08:21+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=c546ee3bb5a8d7469ea6db86f21963dc04913c30'/>
<id>c546ee3bb5a8d7469ea6db86f21963dc04913c30</id>
<content type='text'>
Queue#freeze uses the same C function, so SizedQueue#freeze can use
that via normal method lookup.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Queue#freeze uses the same C function, so SizedQueue#freeze can use
that via normal method lookup.
</pre>
</div>
</content>
</entry>
<entry>
<title>[DOC] Adjust some new features wording/examples. (#9183)</title>
<updated>2023-12-14T21:01:48+00:00</updated>
<author>
<name>Victor Shepelev</name>
<email>zverok.offline@gmail.com</email>
</author>
<published>2023-12-14T21:01:48+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=570d7b2c3e2ee39e07548dfe242b684ec794789d'/>
<id>570d7b2c3e2ee39e07548dfe242b684ec794789d</id>
<content type='text'>
* Reword Range#overlap? docs last paragraph.

* Docs: add explanation about Queue#freeze

* Docs: Add :rescue event docs for TracePoint

* Docs: Enhance Module#set_temporary_name documentation

* Docs: Slightly expand Process::Status deprecations

* Fix MatchData#named_captures rendering glitch

* Improve Dir.fchdir examples

* Adjust Refinement#target docs</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* Reword Range#overlap? docs last paragraph.

* Docs: add explanation about Queue#freeze

* Docs: Add :rescue event docs for TracePoint

* Docs: Enhance Module#set_temporary_name documentation

* Docs: Slightly expand Process::Status deprecations

* Fix MatchData#named_captures rendering glitch

* Improve Dir.fchdir examples

* Adjust Refinement#target docs</pre>
</div>
</content>
</entry>
<entry>
<title>M:N thread scheduler for Ractors</title>
<updated>2023-10-12T05:47:01+00:00</updated>
<author>
<name>Koichi Sasada</name>
<email>ko1@atdot.net</email>
</author>
<published>2023-04-10T01:53:13+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=be1bbd5b7d40ad863ab35097765d3754726bbd54'/>
<id>be1bbd5b7d40ad863ab35097765d3754726bbd54</id>
<content type='text'>
This patch introduce M:N thread scheduler for Ractor system.

In general, M:N thread scheduler employs N native threads (OS threads)
to manage M user-level threads (Ruby threads in this case).
On the Ruby interpreter, 1 native thread is provided for 1 Ractor
and all Ruby threads are managed by the native thread.

From Ruby 1.9, the interpreter uses 1:1 thread scheduler which means
1 Ruby thread has 1 native thread. M:N scheduler change this strategy.

Because of compatibility issue (and stableness issue of the implementation)
main Ractor doesn't use M:N scheduler on default. On the other words,
threads on the main Ractor will be managed with 1:1 thread scheduler.

There are additional settings by environment variables:

`RUBY_MN_THREADS=1` enables M:N thread scheduler on the main ractor.
Note that non-main ractors use the M:N scheduler without this
configuration. With this configuration, single ractor applications
run threads on M:1 thread scheduler (green threads, user-level threads).

`RUBY_MAX_CPU=n` specifies maximum number of native threads for
M:N scheduler (default: 8).

This patch will be reverted soon if non-easy issues are found.

[Bug #19842]
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This patch introduce M:N thread scheduler for Ractor system.

In general, M:N thread scheduler employs N native threads (OS threads)
to manage M user-level threads (Ruby threads in this case).
On the Ruby interpreter, 1 native thread is provided for 1 Ractor
and all Ruby threads are managed by the native thread.

From Ruby 1.9, the interpreter uses 1:1 thread scheduler which means
1 Ruby thread has 1 native thread. M:N scheduler change this strategy.

Because of compatibility issue (and stableness issue of the implementation)
main Ractor doesn't use M:N scheduler on default. On the other words,
threads on the main Ractor will be managed with 1:1 thread scheduler.

There are additional settings by environment variables:

`RUBY_MN_THREADS=1` enables M:N thread scheduler on the main ractor.
Note that non-main ractors use the M:N scheduler without this
configuration. With this configuration, single ractor applications
run threads on M:1 thread scheduler (green threads, user-level threads).

`RUBY_MAX_CPU=n` specifies maximum number of native threads for
M:N scheduler (default: 8).

This patch will be reverted soon if non-easy issues are found.

[Bug #19842]
</pre>
</div>
</content>
</entry>
<entry>
<title>Make {Queue,SizedQueue}#freeze raise TypeError</title>
<updated>2023-09-27T18:57:50+00:00</updated>
<author>
<name>Jeremy Evans</name>
<email>code@jeremyevans.net</email>
</author>
<published>2023-09-26T22:31:55+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=62181e17da2db729eb6d95f6edff9e028ff557b6'/>
<id>62181e17da2db729eb6d95f6edff9e028ff557b6</id>
<content type='text'>
Fixes [Bug #17146]
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Fixes [Bug #17146]
</pre>
</div>
</content>
</entry>
<entry>
<title>Try default `gcc` 9.4.0 to see if it exhibits the same compiler bugs. (#8394)</title>
<updated>2023-09-08T08:44:46+00:00</updated>
<author>
<name>Samuel Williams</name>
<email>samuel.williams@oriontransfer.co.nz</email>
</author>
<published>2023-09-08T08:44:46+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=be21a056d229652ae5cf6926e96c1517aa43453f'/>
<id>be21a056d229652ae5cf6926e96c1517aa43453f</id>
<content type='text'>
* Revert "Extract `do_mutex_lock_check_interrupts` to try and fix `ppc64le`. (#8393)"

This reverts commit 5184b40dd4dc446660cd35c3e53896324e95b317.

* .travis.yml: Try default gcc 9.4.0 instead of gcc-10 in ppc64le and s390x.

Use gcc 9.4.0 instead of gcc-10 to avoid the current failures by a possible GCC
10 compiler bug in the Travis ppc64le and s390x cases. And it also aligns with
RubyCI Ubuntu ppc64le and s390x where the default gcc is used.

---------

Co-authored-by: Jun Aruga &lt;jaruga@ruby-lang.org&gt;</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* Revert "Extract `do_mutex_lock_check_interrupts` to try and fix `ppc64le`. (#8393)"

This reverts commit 5184b40dd4dc446660cd35c3e53896324e95b317.

* .travis.yml: Try default gcc 9.4.0 instead of gcc-10 in ppc64le and s390x.

Use gcc 9.4.0 instead of gcc-10 to avoid the current failures by a possible GCC
10 compiler bug in the Travis ppc64le and s390x cases. And it also aligns with
RubyCI Ubuntu ppc64le and s390x where the default gcc is used.

---------

Co-authored-by: Jun Aruga &lt;jaruga@ruby-lang.org&gt;</pre>
</div>
</content>
</entry>
</feed>
