summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ruby.c4
-rw-r--r--test/ruby/test_rubyoptions.rb2
-rw-r--r--thread_pthread.c35
-rw-r--r--version.c12
4 files changed, 24 insertions, 29 deletions
diff --git a/ruby.c b/ruby.c
index 4f29a5b98a..0efe4efbf4 100644
--- a/ruby.c
+++ b/ruby.c
@@ -2101,7 +2101,10 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt)
opt->yjit = true; // set opt->yjit for Init_ruby_description() and calling rb_yjit_init()
}
#endif
+
+ ruby_mn_threads_params();
Init_ruby_description(opt);
+
if (opt->dump & (DUMP_BIT(version) | DUMP_BIT(version_v))) {
ruby_show_version();
if (opt->dump & DUMP_BIT(version)) return Qtrue;
@@ -2153,7 +2156,6 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt)
#endif
ruby_gc_set_params();
- ruby_mn_threads_params();
ruby_init_loadpath();
Init_enc();
diff --git a/test/ruby/test_rubyoptions.rb b/test/ruby/test_rubyoptions.rb
index 191c0c2278..16cff9754a 100644
--- a/test/ruby/test_rubyoptions.rb
+++ b/test/ruby/test_rubyoptions.rb
@@ -156,7 +156,7 @@ class TestRubyOptions < Test::Unit::TestCase
VERSION_PATTERN_WITH_RJIT =
case RUBY_ENGINE
when 'ruby'
- /^ruby #{q[RUBY_VERSION]}(?:[p ]|dev|rc).*? \+RJIT \[#{q[RUBY_PLATFORM]}\]$/
+ /^ruby #{q[RUBY_VERSION]}(?:[p ]|dev|rc).*? \+RJIT (\+MN )?\[#{q[RUBY_PLATFORM]}\]$/
else
VERSION_PATTERN
end
diff --git a/thread_pthread.c b/thread_pthread.c
index 10b956373d..4211074a74 100644
--- a/thread_pthread.c
+++ b/thread_pthread.c
@@ -1626,6 +1626,8 @@ Init_native_thread(rb_thread_t *main_th)
vm->ractor.sched.dnt_cnt = 1;
}
+extern int ruby_mn_threads_enabled;
+
void
ruby_mn_threads_params(void)
{
@@ -1633,38 +1635,19 @@ ruby_mn_threads_params(void)
rb_ractor_t *main_ractor = GET_RACTOR();
const char *mn_threads_cstr = getenv("RUBY_MN_THREADS");
- bool enable_mn_threads;
+ bool enable_mn_threads = false;
- if (mn_threads_cstr && (enable_mn_threads = atoi(mn_threads_cstr) > 0)) {
-#if USE_MN_THREADS
- if (RTEST(ruby_verbose)) {
- fprintf(stderr, "RUBY_MN_THREADS = %s (default: 0)\n", mn_threads_cstr);
- }
-#else
- enable_mn_threads = false;
- if (RTEST(ruby_verbose)) {
- fprintf(stderr, "RUBY_MN_THREADS = %s is specified, but MN threads are not implemented on this executable.", mn_threads_cstr);
- }
-#endif
- }
- else {
- enable_mn_threads = false; // default: off on main Ractor
+ if (USE_MN_THREADS && mn_threads_cstr && (enable_mn_threads = atoi(mn_threads_cstr) > 0)) {
+ // enabled
+ ruby_mn_threads_enabled = 1;
}
main_ractor->threads.sched.enable_mn_threads = enable_mn_threads;
const char *max_cpu_cstr = getenv("RUBY_MAX_CPU");
const int default_max_cpu = 8; // TODO: CPU num?
- int max_cpu;
- if (max_cpu_cstr && (max_cpu = atoi(max_cpu_cstr)) > 0) {
- if (RTEST(ruby_verbose)) {
-#if USE_MN_THREADS
- fprintf(stderr, "RUBY_MAX_CPU = %d (default: %d)\n", max_cpu, default_max_cpu);
-#else
- fprintf(stderr, "RUBY_MAX_CPU = %d is specified, but MN threads are not implemented on this executable.", max_cpu);
-#endif
- }
- }
- else {
+ int max_cpu = default_max_cpu;
+
+ if (USE_MN_THREADS && max_cpu_cstr && (max_cpu = atoi(max_cpu_cstr)) > 0) {
max_cpu = default_max_cpu;
}
diff --git a/version.c b/version.c
index e5d5bfa561..5f4db2a622 100644
--- a/version.c
+++ b/version.c
@@ -139,12 +139,15 @@ Init_version(void)
#define YJIT_OPTS_ON 0
#endif
+int ruby_mn_threads_enabled;
+
void
Init_ruby_description(ruby_cmdline_options_t *opt)
{
static char desc[
sizeof(ruby_description)
+ rb_strlen_lit(YJIT_DESCRIPTION)
+ + rb_strlen_lit(" +MN")
];
const char *const jit_opt =
@@ -152,9 +155,16 @@ Init_ruby_description(ruby_cmdline_options_t *opt)
YJIT_OPTS_ON ? YJIT_DESCRIPTION :
"";
- int n = snprintf(desc, sizeof(desc), "%.*s" /* jit_opt */"%s" "%s",
+ const char *const threads_opt = ruby_mn_threads_enabled ? " +MN" : "";
+
+ int n = snprintf(desc, sizeof(desc),
+ "%.*s"
+ "%s" // jit_opt
+ "%s" // threads_opts
+ "%s",
ruby_description_opt_point, ruby_description,
jit_opt,
+ threads_opt,
ruby_description + ruby_description_opt_point);
VALUE description = rb_obj_freeze(rb_usascii_str_new_static(desc, n));