Project

General

Profile

Actions

Bug #20604

closed

Performance regression in C++ extensions due to lack of optimization flags by default since Ruby 2.7

Added by ntkme (Natsuki Natsume) 15 days ago. Updated 6 days ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
ruby 3.3.3 (2024-06-12 revision f1c7b6f435) [arm64-darwin23]
[ruby-core:118419]

Description

I found a significant performance regression in sassc gem when comparing Ruby 2.6 and later, that the extension is running more than 10x slower.

I have tracked it down to this commit: https://github.com/ruby/ruby/commit/733aa2f8b578d03bbcb91d2f496b01e3b990c7e8

This commit removed all default CXXFLAGS from RbConfig that were previously set, including $optflags, which has -O3.

Many of the C++ extensions like sassc use extconf/mkmf to compile, and they have assumed optflags are already set for CXXFLAGS. Without -O3 as part of the default, the extensions are compiled without any optimizations and thus become extremely slow.

It is difficult for a regular user to find out the reason of the slowness, nor to say figuring out how to override CXXFLAGS for a native extension.

I'm not sure what was the reason of the change, but I think we should at least set $optflags in CXXFLAGS by default.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like1