Issue #16837 has been updated by nobu (Nobuyoshi Nakada).
Not only assertions, some optimizations can no longer be applied.
For instance, `rb_str_new_cstr` was defined as following in 2.7,
```C
#define rb_str_new_cstr(str) RB_GNUC_EXTENSION_BLOCK( \
(__builtin_constant_p(str)) ? \
rb_str_new_static((str), (long)strlen(str)) : \
rb_str_new_cstr(str) \
)
```
and `rb_str_new_cstr("...")` has been expected to be compiled as `rb_str_new_static("...", 3)`.
The below is the master version.
```C
static inline VALUE
ruby3_str_new_cstr(const char *str)
{
if /* constexpr */ (! RUBY3_CONSTANT_P(str)) {
return rb_str_new_cstr(str);
}
else {
long len = ruby3_strlen(str);
return rb_str_new_static(str, len);
}
}
```
As `str` is an argument variable and `RUBY3_CONSTANT_P(str)` is always false here, `_static` function is never used (in Apple clang 11.0.3 and gcc 10.1.0-RC-20200430_0).
I'm uncertain how this particular case affects the whole performance though, similar un-optimizations might be more.
----------------------------------------
Feature #16837: Can we make Ruby 3.0 as fast as Ruby 2.7 with the new assertions?
https://bugs.ruby-lang.org/issues/16837#change-85451
* Author: k0kubun (Takashi Kokubun)
* Status: Open
* Priority: Normal
----------------------------------------
## Problem
How can we make Ruby 3.0 as fast as (or faster than) Ruby 2.7?
### Background
* Split ruby.h https://github.com/ruby/ruby/pull/2991 added some new assertions
* While it has been helpful for revealing various bugs, it also made some Ruby programs notably slow, especially Optcarrot https://benchmark-driver.github.io/benchmarks/optcarrot/commits.html
## Possible approaches
I have no strong preference yet. Here are some random ideas:
* Optimize the assertion code somehow
* Enable the new assertions only on CIs, at least ones in hot spots
* Not sure which places have large impact on Optcarrot yet
* Make some other not-so-important assertions CI-only to offset the impact from new ones
* Provide .so for an assertion-enabled mode? (ko1's idea)
I hope people will comment more ideas in this ticket.
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>