-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Extend CliMulti to support using symfony/process #22513
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code looks straight forward, only left a minor suggestion for improvement.
Tested running archiving locally, with and without the feature flag enabled and everything still seems to work as expected.
It's thus hard to say if using Symfony Process might introduce any performance decrease.
@tsteur Seems you implemented the improvement around sync requests back then. Can you see any possible problems with using Symfony Process here?
0685507
to
543213c
Compare
I'm not familiar with Symfony Process directly @sgiehl . From a performance point of view it would be just important to launch the process and wait until it's finished (not check regularly if it's finished like we do in async since this can cause a lot of CPU usage from experience). Of course also need to make sure it'll work across all sorts of systems and that we're not regressing anything there. Does this help? |
Symfony is using So to wait for it to finish there has to be an active loop (reuses the existing logic with the slightly increasing 100ms+ sleeps), but the overhead should be far lower. Waiting will be done using How much difference there is between shell_exec and looping? We will need to check the metrics once it is running, but given the improvement we have for asynchronous climulti I would not be surprised by a net benefit overall. Compatibility wise everything is currently wrapped behind checks for some PHP function requirements and a feature flag, so it won't be active unless we explicitly tell the system to use it. Imo that sounds like we are good to give it a try 🤔 |
Be good to measure indeed 👍 On product we saw a lot of overhead with an active loop. see #18157
10-20% overhead would be quite a cost. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As everything is hidden behind a feature flag, let's merge it, so we can give that a try on cloud.
e467182
to
9e49bbc
Compare
Relevant references
With #22394 we plan to use a database based approach to not archive a segment/period more than once. This will introduce a problem with long running archiving processes and server restarts/deployments, because a forced stop of an archiving process can no longer be "rescued" by a higher period archiving process. The stopped invalidation will prevent any further archiving until it is detected as broken and retried (by default after 24 hours).
With #22487 we plan to introduce signal handling into the archiving process to prevent mentioned problems. The intent is to support "stop the current archive after receiving SIGINT" and "abort the current archive after receiving SIGTERM, reset that invalidation so it does not stall archiving".
CliMulti and OS signal handling
The
CliMulti
implementation received a performance improvement in #18157, using a synchronousshell_exec
instead of the concurrent background process implementation, if only a single request is done.A single
shell_exec
can not be intercepted with the featuresext-pcntl
provides, and with archives being able to take hours to complete, we can not provide our plannedSIGTERM
handling without changes. Having a server wait for hours to allow a clean shutdown of the archiving run would match our plannedSIGINT
handling, butSIGTERM
should allow for an immediate shutdown. Especially when using costly cloud provider instances.One way to solve our problem would be to revert the #18157 improvement, it would work (test implementation, CI run) for our use case.
Symfony/Process alternative
This PR provides the alternative route of integrating
symfony/process
to replace our customshell_exec
implementation. Symfony is usingproc_open
instead ofshell_exec
, and should have a lower footprint compared to the custom output pipe/file handling used byCliMulti
.Some noteworthy details on the PR implementation:
VisitorGenerator
tests fail becausesymfony/process
is already integrated there. Should be taken care of if we decide to go with the approach of this PRCliMulti
is using a feature flag and is quite defensive. This should allow us to work around any problems in the update process, with the current implementation taking over gracefully.Review