Skip to content

Commit

Permalink
Add a new system config 'enable_jit'
Browse files Browse the repository at this point in the history
This adds a new option to enable Ruby JIT in worker processes.

The exact JIT strategy (in particular mjit or yjit) will be chosen
by Ruby as it sees fit. See the following ticket for details:

    https://bugs.ruby-lang.org/issues/18349

Signed-off-by: Fujimoto Seiji <[email protected]>
  • Loading branch information
fujimotos committed Aug 13, 2022
1 parent cf241f0 commit 7515917
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lib/fluent/supervisor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1104,6 +1104,11 @@ def build_spawn_command
fluentd_spawn_cmd << '-Eascii-8bit:ascii-8bit'
end

if @system_config.enable_jit
$log.info "enable Ruby JIT for workers"
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
3 changes: 2 additions & 1 deletion lib/fluent/system_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class SystemConfig
:without_source, :rpc_endpoint, :enable_get_dump, :process_name,
:file_permission, :dir_permission, :counter_server, :counter_client,
:strict_config_value, :enable_msgpack_time_support, :disable_shared_socket,
:metrics, :enable_input_metrics, :enable_size_metrics
:metrics, :enable_input_metrics, :enable_size_metrics, :enable_jit
]

config_param :workers, :integer, default: 1
Expand All @@ -50,6 +50,7 @@ class SystemConfig
config_param :disable_shared_socket, :bool, default: nil
config_param :enable_input_metrics, :bool, default: nil
config_param :enable_size_metrics, :bool, default: nil
config_param :enable_jit, :bool, default: false
config_param :file_permission, default: nil do |v|
v.to_i(8)
end
Expand Down
2 changes: 2 additions & 0 deletions test/config/test_system_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def parse_text(text)
assert_nil(sc.enable_input_metrics)
assert_nil(sc.enable_size_metrics)
assert_nil(sc.enable_msgpack_time_support)
assert(!sc.enable_jit)
assert_equal(:text, sc.log.format)
assert_equal('%Y-%m-%d %H:%M:%S %z', sc.log.time_format)
end
Expand All @@ -102,6 +103,7 @@ def parse_text(text)
'enable_msgpack_time_support' => ['enable_msgpack_time_support', true],
'enable_input_metrics' => ['enable_input_metrics', true],
'enable_size_metrics' => ['enable_size_metrics', true],
'enable_jit' => ['enable_jit', true],
)
test "accepts parameters" do |(k, v)|
conf = parse_text(<<-EOS)
Expand Down

0 comments on commit 7515917

Please sign in to comment.