<feed xmlns='http://www.w3.org/2005/Atom'>
<title>ruby.git/thread_pthread_mn.c, branch v3_3_11</title>
<subtitle>The Ruby Programming Language</subtitle>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/'/>
<entry>
<title>merge revision(s) ffc69eec0a5746d48ef3cf649639c67631a6a609, 0531fa4d6fea100f69f0bac9e03973fe49ecd570: [Backport #21560]</title>
<updated>2025-11-02T05:50:06+00:00</updated>
<author>
<name>nagachika</name>
<email>nagachika@ruby-lang.org</email>
</author>
<published>2025-11-02T05:50:06+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=609f957ebede1a062b1f34515382e4c306f77444'/>
<id>609f957ebede1a062b1f34515382e4c306f77444</id>
<content type='text'>
	[PATCH] `struct rb_thread_sched_waiting`

	Introduce `struct rb_thread_sched_waiting` and `timer_th.waiting`
	can contain other than `rb_thread_t`.

	[PATCH] mn timer thread: force wakeups for timeouts
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
	[PATCH] `struct rb_thread_sched_waiting`

	Introduce `struct rb_thread_sched_waiting` and `timer_th.waiting`
	can contain other than `rb_thread_t`.

	[PATCH] mn timer thread: force wakeups for timeouts
</pre>
</div>
</content>
</entry>
<entry>
<title>MN: access `timer_th.waiting` with lock</title>
<updated>2023-12-24T01:57:27+00:00</updated>
<author>
<name>Koichi Sasada</name>
<email>ko1@atdot.net</email>
</author>
<published>2023-12-24T01:30:03+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=82015496b924744ae3999987ba679978beb153c7'/>
<id>82015496b924744ae3999987ba679978beb153c7</id>
<content type='text'>
`timer_th.waiting` should be protected by `timer_th.waiting_lock`
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
`timer_th.waiting` should be protected by `timer_th.waiting_lock`
</pre>
</div>
</content>
</entry>
<entry>
<title>Replicate EEXIST epoll_ctl behavior in kqueue</title>
<updated>2023-12-23T22:07:11+00:00</updated>
<author>
<name>JP Camara</name>
<email>jp@jpcamara.com</email>
</author>
<published>2023-12-23T01:28:55+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=a2ebf9cc63f0805bc7dd9a92e66bf589a869447e'/>
<id>a2ebf9cc63f0805bc7dd9a92e66bf589a869447e</id>
<content type='text'>
* In the epoll implementation, you get an EEXIST if you try to register the same event for the same fd more than once for a particular epoll instance

* Otherwise kevent will just override the previous event registration, and if multiple threads listen on the same fd only the last one to register will ever finish, the others are stuck

* This approach will lead to native threads getting created, similar to the epoll implementation. This is not ideal, but it fixes certain test cases for now, like test/socket/test_tcp.rb#test_accept_multithread
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* In the epoll implementation, you get an EEXIST if you try to register the same event for the same fd more than once for a particular epoll instance

* Otherwise kevent will just override the previous event registration, and if multiple threads listen on the same fd only the last one to register will ever finish, the others are stuck

* This approach will lead to native threads getting created, similar to the epoll implementation. This is not ideal, but it fixes certain test cases for now, like test/socket/test_tcp.rb#test_accept_multithread
</pre>
</div>
</content>
</entry>
<entry>
<title>skip `MAP_STACK` on FreeBSD</title>
<updated>2023-12-20T08:00:55+00:00</updated>
<author>
<name>Koichi Sasada</name>
<email>ko1@atdot.net</email>
</author>
<published>2023-12-20T06:48:49+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=4927f251481df57a209284bb2ad2b237468e7792'/>
<id>4927f251481df57a209284bb2ad2b237468e7792</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Hand thread into `thread_sched_wait_events_timeval`</title>
<updated>2023-12-20T07:23:38+00:00</updated>
<author>
<name>JP Camara</name>
<email>jp@jpcamara.com</email>
</author>
<published>2023-12-16T03:39:45+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=256f34ab6b221b630e5e4ec8d39e3808e82a3296'/>
<id>256f34ab6b221b630e5e4ec8d39e3808e82a3296</id>
<content type='text'>
* When we have the thread already, it saves a lookup

* `event_wait`, not `kq`

Clean up the `thread_sched_wait_events_timeval` calls

* By handling the PTHREAD check inside the function, all the other code can become much simpler and just call the function directly without additional checks
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* When we have the thread already, it saves a lookup

* `event_wait`, not `kq`

Clean up the `thread_sched_wait_events_timeval` calls

* By handling the PTHREAD check inside the function, all the other code can become much simpler and just call the function directly without additional checks
</pre>
</div>
</content>
</entry>
<entry>
<title>KQueue support for M:N threads</title>
<updated>2023-12-20T07:23:38+00:00</updated>
<author>
<name>JP Camara</name>
<email>jp@jpcamara.com</email>
</author>
<published>2023-12-07T01:01:14+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=8782e02138e6fe18b6c0dcc29bb877d6cdae57e5'/>
<id>8782e02138e6fe18b6c0dcc29bb877d6cdae57e5</id>
<content type='text'>
* Allows macOS users to use M:N threads (and technically FreeBSD, though it has not been verified on FreeBSD)

* Include sys/event.h header check for macros, and include sys/event.h when present

* Rename epoll_fd to more generic kq_fd (Kernel event Queue) for use by both epoll and kqueue

* MAP_STACK is not available on macOS so conditionall apply it to mmap flags

* Set fd to close on exec

* Log debug messages specific to kqueue and epoll on creation

* close_invalidate raises an error for the kqueue fd on child process fork. It's unclear rn if that's a bug, or if it's kqueue specific behavior

Use kq with rb_thread_wait_for_single_fd

* Only platforms with `USE_POLL` (linux) had changes applied to take advantage of kernel event queues. It needed to be applied to the `select` so that kqueue could be properly applied

* Clean up kqueue specific code and make sure only flags that were actually set are removed (or an error is raised)

* Also handle kevent specific errnos, since most don't apply from epoll to kqueue

* Use the more platform standard close-on-exec approach of `fcntl` and `FD_CLOEXEC`. The io-event gem uses `ioctl`, but fcntl seems to be the recommended choice. It is also what Go, Bun, and Libuv use

* We're making changes in this file anyways - may as well fix a couple spelling mistakes while here

Make sure FD_CLOEXEC carries over in dup

* Otherwise the kqueue descriptor should have FD_CLOEXEC, but doesn't and fails in assert_close_on_exec
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* Allows macOS users to use M:N threads (and technically FreeBSD, though it has not been verified on FreeBSD)

* Include sys/event.h header check for macros, and include sys/event.h when present

* Rename epoll_fd to more generic kq_fd (Kernel event Queue) for use by both epoll and kqueue

* MAP_STACK is not available on macOS so conditionall apply it to mmap flags

* Set fd to close on exec

* Log debug messages specific to kqueue and epoll on creation

* close_invalidate raises an error for the kqueue fd on child process fork. It's unclear rn if that's a bug, or if it's kqueue specific behavior

Use kq with rb_thread_wait_for_single_fd

* Only platforms with `USE_POLL` (linux) had changes applied to take advantage of kernel event queues. It needed to be applied to the `select` so that kqueue could be properly applied

* Clean up kqueue specific code and make sure only flags that were actually set are removed (or an error is raised)

* Also handle kevent specific errnos, since most don't apply from epoll to kqueue

* Use the more platform standard close-on-exec approach of `fcntl` and `FD_CLOEXEC`. The io-event gem uses `ioctl`, but fcntl seems to be the recommended choice. It is also what Go, Bun, and Libuv use

* We're making changes in this file anyways - may as well fix a couple spelling mistakes while here

Make sure FD_CLOEXEC carries over in dup

* Otherwise the kqueue descriptor should have FD_CLOEXEC, but doesn't and fails in assert_close_on_exec
</pre>
</div>
</content>
</entry>
<entry>
<title>Add missing GVL hooks for M:N threads and ractors</title>
<updated>2023-12-09T17:31:41+00:00</updated>
<author>
<name>John Hawthorn</name>
<email>john@hawthorn.email</email>
</author>
<published>2023-12-09T05:16:02+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=b2ad4fec1a369e1cbd0c65d52062946a4fbfb84b'/>
<id>b2ad4fec1a369e1cbd0c65d52062946a4fbfb84b</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Revert "Add missing GVL hooks for M:N threads and ractors"</title>
<updated>2023-12-04T02:37:06+00:00</updated>
<author>
<name>John Hawthorn</name>
<email>john@hawthorn.email</email>
</author>
<published>2023-12-04T02:13:25+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=85bc80a51be0ceedcc57e7b6b779e6f8f885859e'/>
<id>85bc80a51be0ceedcc57e7b6b779e6f8f885859e</id>
<content type='text'>
This reverts commit ad54fbf281ca1935e79f4df1460b0106ba76761e.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This reverts commit ad54fbf281ca1935e79f4df1460b0106ba76761e.
</pre>
</div>
</content>
</entry>
<entry>
<title>Add missing GVL hooks for M:N threads and ractors</title>
<updated>2023-12-02T18:06:07+00:00</updated>
<author>
<name>John Hawthorn</name>
<email>john@hawthorn.email</email>
</author>
<published>2023-11-29T23:54:32+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=ad54fbf281ca1935e79f4df1460b0106ba76761e'/>
<id>ad54fbf281ca1935e79f4df1460b0106ba76761e</id>
<content type='text'>
[Bug #20019]

This fixes GVL instrumentation in three locations it was missing:
- Suspending when blocking on a Ractor
- Suspending when doing a coroutine transfer from an M:N thread
- Resuming after an M:N thread starts

Co-authored-by: Matthew Draper &lt;matthew@trebex.net&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[Bug #20019]

This fixes GVL instrumentation in three locations it was missing:
- Suspending when blocking on a Ractor
- Suspending when doing a coroutine transfer from an M:N thread
- Resuming after an M:N thread starts

Co-authored-by: Matthew Draper &lt;matthew@trebex.net&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Cast up before multiplication</title>
<updated>2023-10-29T12:27:49+00:00</updated>
<author>
<name>Nobuyoshi Nakada</name>
<email>nobu@ruby-lang.org</email>
</author>
<published>2023-10-29T12:27:49+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=fbd55120f3c58dc7d16b3870a8f36f07277bb338'/>
<id>fbd55120f3c58dc7d16b3870a8f36f07277bb338</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
</feed>
