Issue #16837 has been updated by k0kubun (Takashi Kokubun).


> I would like to suggest that if a user really favor speed over sanity check, they should just compiler everything with -DNDEBUG. This has been the standard C manner since long before Ruby's birth.

Got it. I'll consider using -DNDEBUG in benchmark servers at least. Also maybe it's worth noting it in NEWS for those who package Ruby for performance-sensitive usages?

> An obvious ad-hoc remedy is to supply `__attribute__((__always_inline__))` for everything. But I don't think that's a good idea, because what is inlined and what is not depends very much on compilers, versions, target architectures, and almost everything.

Agreed. While it's not a good idea to always inline *everything*, some may be worth a consideration though.

> I assume for a .so file the ruby user would have to require/load that file

His idea was to install the .so file to Ruby prefix by default and add a `--debug-xxx` option to load it.

----------------------------------------
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-85432

* 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>