From: "osyoyu (Daisuke Aritomo) via ruby-core" <ruby-core@ml.ruby-lang.org>
To: ruby-core@ml.ruby-lang.org
Cc: "osyoyu (Daisuke Aritomo)" <noreply@ruby-lang.org>
Subject: [ruby-core:116347] [Ruby master Bug#20197] Postponed job invocations are significantly reduced in Ruby 3.3
Date: Sat, 20 Jan 2024 15:58:44 +0000 (UTC) [thread overview]
Message-ID: <redmine.issue-20197.20240120155844.10855@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-20197.20240120155844.10855@ruby-lang.org
Issue #20197 has been reported by osyoyu (Daisuke Aritomo).
----------------------------------------
Bug #20197: Postponed job invocations are significantly reduced in Ruby 3.3
https://bugs.ruby-lang.org/issues/20197
* Author: osyoyu (Daisuke Aritomo)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-linux]
* Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN
----------------------------------------
The number of postponed job invocations has been significantly reduced in Ruby 3.3.
While my understanding is that postponed jobs provide no guarantee of how soon registered callbacks will fire, I believe the current rate is too low for practical usage, especially for profilers such as StackProf.
A git bisect led me to https://github.com/ruby/ruby/commit/1f0304218cf00e05a4a126196676ba221ebf91f6 which obviously seems to be related, but I'm not sure why.
## Repro
### Expected
The job fires (nearly) every 100 ms.
```
% ruby bin/test.rb # runs for 3 seconds
count: 1
count: 2
(snip)
count: 29
```
### Actual
The job fires only once.
```
% ruby bin/test.rb
count: 1
count: 2
(snip)
count: 29
```
### Code
```ruby
require 'mycext'
time = Time.now
th = Thread.new do
loop do
sleep 0.01
break if Time.now - time > 3 # run for 3 seconds
end
end
th.join
```
```c
#include <pthread.h>
#include <stdio.h>
#include <time.h>
#include "ruby.h"
#include "ruby/debug.h"
int called_count;
void
postponed_job(void *ptr)
{
called_count++;
printf("count: %d\n", called_count);
}
_Noreturn void *
pthread_main(void *_)
{
while (1) {
rb_postponed_job_register_one(0, postponed_job, NULL);
// Sleep for 100 ms
struct timespec ts;
ts.tv_sec = 0;
ts.tv_nsec = 100 * 1000 * 1000;
nanosleep(&ts, NULL);
}
}
RUBY_FUNC_EXPORTED void
Init_mycext(void)
{
called_count = 0;
pthread_t pthread;
pthread_create(&pthread, NULL, pthread_main, NULL);
}
```
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/
next parent reply other threads:[~2024-01-20 15:58 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-20 15:58 osyoyu (Daisuke Aritomo) via ruby-core [this message]
2024-01-20 22:01 ` [ruby-core:116349] [Ruby master Bug#20197] Postponed job invocations are significantly reduced in Ruby 3.3 kjtsanaktsidis (KJ Tsanaktsidis) via ruby-core
2024-01-21 9:15 ` [ruby-core:116353] " byroot (Jean Boussier) via ruby-core
2024-01-22 5:29 ` [ruby-core:116362] " kjtsanaktsidis (KJ Tsanaktsidis) via ruby-core
2024-01-22 12:03 ` [ruby-core:116365] " osyoyu (Daisuke Aritomo) via ruby-core
2024-01-25 9:09 ` [ruby-core:116440] " byroot (Jean Boussier) via ruby-core
2024-01-25 11:26 ` [ruby-core:116441] " kjtsanaktsidis (KJ Tsanaktsidis) via ruby-core
2024-03-20 12:48 ` [ruby-core:117258] " naruse (Yui NARUSE) via ruby-core
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.ruby-lang.org/en/community/mailing-lists/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=redmine.issue-20197.20240120155844.10855@ruby-lang.org \
--to=ruby-core@ruby-lang.org \
--cc=noreply@ruby-lang.org \
--cc=ruby-core@ml.ruby-lang.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).