Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
uses: ruby/actions/.github/workflows/ruby_versions.yml@master
with:
engine: cruby
min_version: 3.2
min_version: 3.3
test:
needs: ruby-versions
runs-on: ${{ matrix.os }}
Expand All @@ -38,8 +38,6 @@ jobs:
- ruby-version: head
- os: 'windows-11-arm'
ruby-version: '3.3'
- os: 'windows-11-arm'
ruby-version: '3.2'
env:
RUBYOPT: "--disable-frozen_string_literal"
name: Ruby ${{ matrix.ruby-version }} on ${{ matrix.os }}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Fluentd: Open-Source Log Collector

### Prerequisites

- Ruby 3.2 or later
- Ruby 3.3 or later
- git

`git` should be in `PATH`. On Windows, you can use `Github for Windows` and `GitShell` for easy setup.
Expand Down
2 changes: 1 addition & 1 deletion fluentd.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Gem::Specification.new do |gem|
gem.metadata["changelog_uri"] = "https://github.com/fluent/fluentd/blob/master/CHANGELOG.md"
gem.metadata["bug_tracker_uri"] = "https://github.com/fluent/fluentd/issues"

gem.required_ruby_version = '>= 3.2'
gem.required_ruby_version = '>= 3.3'

gem.add_runtime_dependency("bundler")
gem.add_runtime_dependency("msgpack", [">= 1.3.1", "< 2.0.0"])
Expand Down
19 changes: 14 additions & 5 deletions lib/fluent/supervisor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,7 @@ def run_worker
MessagePackFactory.init(enable_time_support: @system_config.enable_msgpack_time_support)
Fluent::Engine.init(@system_config, start_in_parallel: ENV.key?("FLUENT_RUNNING_IN_PARALLEL_WITH_OLD"))
Fluent::Engine.run_configure(@conf)
enable_ruby_jit if @system_config.enable_jit
Fluent::Engine.run
self.class.cleanup_socketmanager_path if @standalone_worker
exit 0
Expand Down Expand Up @@ -1214,6 +1215,19 @@ def main_process(&block)
exit!(unrecoverable_error ? 2 : 1)
end

def enable_ruby_jit
unless defined?(RubyVM::YJIT) && RubyVM::YJIT.respond_to?(:enable)
$log.info "Ruby JIT is not available on this Ruby"
return
end

if RubyVM::YJIT.enable
$log.info "enabled Ruby JIT"
else
$log.warn "failed to enable Ruby JIT"
end
end

def build_system_config(conf)
system_config = SystemConfig.create(conf, @cl_opt[:strict_config_value])
# Prefer the options explicitly specified in the command line
Expand Down Expand Up @@ -1281,11 +1295,6 @@ def build_spawn_command
fluentd_spawn_cmd << '-Eascii-8bit:ascii-8bit'
end

if @system_config.enable_jit
$log.info "enable Ruby JIT for workers (--jit)"
fluentd_spawn_cmd << '--jit'
end

# Adding `-h` so that it can avoid ruby's command blocking
# e.g. `ruby -Eascii-8bit:ascii-8bit` will block. but `ruby -Eascii-8bit:ascii-8bit -h` won't.
_, e, s = Open3.capture3(*fluentd_spawn_cmd, "-h")
Expand Down
2 changes: 1 addition & 1 deletion lib/fluent/system_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class SystemConfig
config_param :disable_shared_socket, :bool, default: nil
config_param :enable_input_metrics, :bool, default: true
config_param :enable_size_metrics, :bool, default: nil
config_param :enable_jit, :bool, default: false
config_param :enable_jit, :bool, default: true
config_param :file_permission, default: nil do |v|
v.to_i(8)
end
Expand Down
4 changes: 2 additions & 2 deletions test/config/test_system_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def parse_text(text)
assert_true(sc.enable_input_metrics)
assert_nil(sc.enable_size_metrics)
assert_nil(sc.enable_msgpack_time_support)
assert(!sc.enable_jit)
assert(sc.enable_jit)
assert_nil(sc.log.path)
assert_equal(:text, sc.log.format)
assert_equal('%Y-%m-%d %H:%M:%S %z', sc.log.time_format)
Expand All @@ -100,7 +100,7 @@ def parse_text(text)
'enable_msgpack_time_support' => ['enable_msgpack_time_support', true],
'enable_input_metrics' => ['enable_input_metrics', false],
'enable_size_metrics' => ['enable_size_metrics', true],
'enable_jit' => ['enable_jit', true],
'enable_jit' => ['enable_jit', false],
'umask' => ['umask', '0022'],
)
test "accepts parameters" do |(k, v)|
Expand Down
46 changes: 46 additions & 0 deletions test/test_supervisor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -957,6 +957,52 @@ def server.config
end
end

sub_test_case "enable_jit" do
setup do
omit "YJIT is not supported on Windows, and RubyVM::YJIT is not defined either" if Fluent.windows?
end

def create_worker(enable_jit)
sv = Fluent::Supervisor.new({})
conf = Fluent::Config::Element.new(
'ROOT', '', {}, [Fluent::Config::Element.new('system', '', { 'enable_jit' => enable_jit.to_s }, [])]
)
sv.instance_variable_set(:@system_config, sv.__send__(:build_system_config, conf))
sv.instance_variable_set(:@conf, conf)
sv
end

data("enabled" => [true, 1],
"disabled" => [false, 0])
def test_run_worker((enable_jit, expected_count))
sv = create_worker(enable_jit)

stub(sv).install_main_process_signal_handlers
stub(Fluent::MessagePackFactory).init
stub(Fluent::Engine).init
stub(Fluent::Engine).run_configure
stub(Fluent::Engine).run

enable_count = 0
stub(RubyVM::YJIT).enable { enable_count += 1; true }

assert_raise(SystemExit) { sv.run_worker }
assert_equal(expected_count, enable_count)
end

data("succeeded" => [true, "enabled Ruby JIT"],
"failed" => [false, "failed to enable Ruby JIT"])
def test_log_result((result, expected_message))
sv = create_worker(true)
create_info_dummy_logger

mock(RubyVM::YJIT).enable { result }
sv.__send__(:enable_ruby_jit)

assert { $log.out.logs.any? { |log| log.include?(expected_message) } }
end
end

sub_test_case "zero_downtime_restart" do
setup do
omit "Not supported on Windows" if Fluent.windows?
Expand Down