-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
daemon: Fix slow start with Ruby 3 #85
base: main
Are you sure you want to change the base?
Conversation
This does not change any specification. This just changes to use a Ruby thread instead of `CreateThread`. It is very very fast to use a Ruby thread from the beginning. Service startup is noticeably slower with Ruby 3. (Please see chef#84). Windows service needs to finish `StartServiceCtrlDispatcher` in 30 seconds by default. With Ruby 3 or later, this problem can cause timeout errors. The more CPUs, the slower it tends to be. Maybe some implementation about threading has changed with Ruby 3 series. The current implementation switches between multiple Ruby threads and non-Ruby threads. This complex process may be unsuitable for Ruby 3. `CreateThread` makes a non-Ruby thread, and it calls Ruby Proc, and it makes a Ruby thread, and ... Signed-off-by: Daijiro Fukuda <[email protected]>
Quality Gate passedIssues Measures |
Only applied this change (inserting --- a/lib/win32/daemon.rb
+++ b/lib/win32/daemon.rb
@@ -265,6 +265,7 @@ module Win32
events.put_pointer(FFI::Pointer.size, FFI::Pointer.new(@@hStartEvent))
while (index = WaitForMultipleObjects(2, events, 0, 1000)) == WAIT_TIMEOUT
+ sleep 0.1
end
if index == WAIT_FAILED
I don't know why, but it's one second slower than this PR. |
Until chef/win32-service#85 is merged, This fix should be applied to fluent-package not to block starting fluentdwinsvc service on Windows. See fluent#618 Signed-off-by: Kentaro Hayashi <[email protected]>
Until chef/win32-service#85 is merged, This fix should be applied to fluent-package not to block starting fluentdwinsvc service on Windows. See fluent#618 Closes: fluent#630 Signed-off-by: Kentaro Hayashi <[email protected]>
Until chef/win32-service#85 is merged, This fix should be applied to fluent-package not to block starting fluentdwinsvc service on Windows. See fluent#618 Closes: fluent#630 Signed-off-by: Kentaro Hayashi <[email protected]>
Until chef/win32-service#85 is merged, This fix should be applied to fluent-package not to block starting fluentdwinsvc service on Windows. See fluent#618 Closes: fluent#630 Signed-off-by: Kentaro Hayashi <[email protected]>
Until chef/win32-service#85 is merged, This fix should be applied to fluent-package not to block starting fluentdwinsvc service on Windows. See fluent#618 Closes: fluent#630 Signed-off-by: Kentaro Hayashi <[email protected]>
Until chef/win32-service#85 is merged, This fix should be applied to fluent-package not to block starting fluentdwinsvc service on Windows. See fluent#618 Closes: fluent#630 Signed-off-by: Kentaro Hayashi <[email protected]>
Until chef/win32-service#85 is merged, This fix should be applied to fluent-package not to block starting fluentdwinsvc service on Windows. See fluent#618 Closes: fluent#630 NOTE: even though just putting the following line does not install forked version of win32-service, so install it explicitly as same as fluentd gem. gem "win32-service", github: "fluent-plugins-nursery/win32-service", branch: "fluent-package", platforms: [:mingw, :x64_mingw] Signed-off-by: Kentaro Hayashi <[email protected]>
Until chef/win32-service#85 is merged, This fix should be applied to fluent-package not to block starting fluentdwinsvc service on Windows. See fluent#618 Closes: fluent#630 NOTE: even though just putting the following line does not install forked version of win32-service, so install it explicitly as same as fluentd gem. gem "win32-service", github: "fluent-plugins-nursery/win32-service", branch: "fluent-package", platforms: [:mingw, :x64_mingw] Signed-off-by: Kentaro Hayashi <[email protected]>
Until chef/win32-service#85 is merged, use forked version of win32-service. This fix should be applied to fluent-package not to block starting fluentdwinsvc service on Windows. See fluent#618 Closes: fluent#630 NOTE: even though just putting the following line does not install forked version of win32-service, so install it explicitly as same as fluentd gem. gem "win32-service", github: "fluent-plugins-nursery/win32-service", branch: "fluent-package", platforms: [:mingw, :x64_mingw] Signed-off-by: Kentaro Hayashi <[email protected]>
Until chef/win32-service#85 is merged, use forked version of win32-service. This fix should be applied to fluent-package not to block starting fluentdwinsvc service on Windows. See fluent#618 Closes: fluent#630 NOTE: even though just putting the following line does not install forked version of win32-service, so install it explicitly as same as fluentd gem. gem "win32-service", github: "fluent-plugins-nursery/win32-service", branch: "fluent-package", platforms: [:mingw, :x64_mingw] Signed-off-by: Kentaro Hayashi <[email protected]>
Until chef/win32-service#85 is merged, use forked version of win32-service. This fix should be applied to fluent-package not to block starting fluentdwinsvc service on Windows. See fluent#618 Closes: fluent#630 NOTE: even though just putting the following line does not install forked version of win32-service, so install it explicitly as same as fluentd gem. gem "win32-service", github: "fluent-plugins-nursery/win32-service", branch: "fluent-package", platforms: [:mingw, :x64_mingw] Signed-off-by: Kentaro Hayashi <[email protected]>
Until chef/win32-service#85 is merged, use forked version of win32-service. This fix should be applied to fluent-package not to block starting fluentdwinsvc service on Windows. See fluent#618 Closes: fluent#630 NOTE: even though just putting the following line does not install forked version of win32-service, so install it explicitly as same as fluentd gem. gem "win32-service", github: "fluent-plugins-nursery/win32-service", branch: "fluent-package", platforms: [:mingw, :x64_mingw] Signed-off-by: Kentaro Hayashi <[email protected]>
Until chef/win32-service#85 is merged, use forked version of win32-service. This fix should be applied to fluent-package not to block starting fluentdwinsvc service on Windows. See fluent#618 Closes: fluent#630 NOTE: even though just putting the following line does not install forked version of win32-service, so install it explicitly as same as fluentd gem. gem "win32-service", github: "fluent-plugins-nursery/win32-service", branch: "fluent-package", platforms: [:mingw, :x64_mingw] Signed-off-by: Kentaro Hayashi <[email protected]>
Until chef/win32-service#85 is merged, use forked version of win32-service. This fix should be applied to fluent-package not to block starting fluentdwinsvc service on Windows. See fluent#618 Closes: fluent#630 NOTE: even though just putting the following line does not install forked version of win32-service, so install it explicitly as same as fluentd gem. gem "win32-service", github: "fluent-plugins-nursery/win32-service", branch: "fluent-package", platforms: [:mingw, :x64_mingw] Signed-off-by: Kentaro Hayashi <[email protected]>
Until chef/win32-service#85 is merged, use forked version of win32-service. This fix should be applied to fluent-package not to block starting fluentdwinsvc service on Windows. See fluent#618 Closes: fluent#630 NOTE: even though just putting the following line does not install forked version of win32-service, so install it explicitly as same as fluentd gem. gem "win32-service", github: "fluent-plugins-nursery/win32-service", branch: "fluent-package", platforms: [:mingw, :x64_mingw] Signed-off-by: Kentaro Hayashi <[email protected]>
Until chef/win32-service#85 is merged, use forked version of win32-service. This fix should be applied to fluent-package not to block starting fluentdwinsvc service on Windows. See #618 Closes: #630 NOTE: even though just putting the following line does not install forked version of win32-service, so install it explicitly as same as fluentd gem. ``` gem "win32-service", github: "fluent-plugins-nursery/win32-service", branch: "fluent-package", platforms: [:mingw, :x64_mingw] ``` Signed-off-by: Kentaro Hayashi <[email protected]>
We use our fork version including this patch for fluent-package. (Please see fluent/fluent-package-builder#618 for details.) We have confirmed this patch dramatically stabilizes service startup time. |
As an additional datapoint - we were hitting these timeout issues after upgrading to Ruby 3.1 and running on AWS. Applying this patch has fixed the startup issues we were hitting - thanks! |
Description
CreateThread
.CreateThread
Win32 APIsleep 0.1
Issues Resolved
Check List
Win32::Service::status dhcp status sets service_type to "share process"
fails on the master on my local. All else succeeds.Comparing the time to start a service
Env:
Service code:
Measurement steps are the same as #84.