diff options
author | Koichi Sasada <[email protected]> | 2020-09-04 05:51:55 +0900 |
---|---|---|
committer | Koichi Sasada <[email protected]> | 2020-09-04 14:18:48 +0900 |
commit | 3b0bcaf2872e5ab6d2475e9cd6dd5c374d93ae0b (patch) | |
tree | bec58277c5c1efe374236f8438661ad633740d13 /ractor_pub.h | |
parent | 169b1d1aca0c26d38f8bbd25ecaf5fdb8015f5cf (diff) |
check multi_ractor mode at main_p
rb_ractor_main_p() need to access to the ractor pointer in TLS.
However it is slow operation so that we need to skip this check
if it is not multi-ractor mode (!ruby_multi_ractor).
This performance regression is pointed at
https://bugs.ruby-lang.org/issues/17100#note-27
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/3513
Diffstat (limited to 'ractor_pub.h')
-rw-r--r-- | ractor_pub.h | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/ractor_pub.h b/ractor_pub.h index 5062782b5a..5347481429 100644 --- a/ractor_pub.h +++ b/ractor_pub.h @@ -1,5 +1,20 @@ +#ifndef RACTOR_PUB_INCLUDED +#define RACTOR_PUB_INCLUDED -int rb_ractor_main_p(void); +RUBY_EXTERN bool ruby_multi_ractor; + +bool rb_ractor_main_p_(void); + +static inline bool +rb_ractor_main_p(void) +{ + if (!ruby_multi_ractor) { + return true; + } + else { + return rb_ractor_main_p_(); + } +} bool rb_ractor_shareable_p_continue(VALUE obj); @@ -31,3 +46,5 @@ void rb_ractor_stdout_set(VALUE); void rb_ractor_stderr_set(VALUE); RUBY_SYMBOL_EXPORT_END + +#endif |