Skip to content
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

core:archive Remember if process ever started #16950

Merged
merged 2 commits into from Dec 15, 2020

Conversation

tsteur
Copy link
Member

@tsteur tsteur commented Dec 14, 2020

This can potentially bring a performance improvement as I think sometimes the system would wait for 8 seconds before declaring a process as finished even if it finished after 1s.

What happens is in https://github.com/matomo-org/matomo/blob/4.0.5/core/CliMulti.php#L217-L222 it checks if the process has started by checking if the PID file exists.

However, the RequestCommand deletes the PID file as soon as the process finished to signal "it finished". That means when we check in that loop whether the process has started, it would think it hasn't started yet and simply continue until 8s have past and then it would set the process as finished. Vs we can simply remember that once we say once "the process has started" flag then we can always remember this.

Actually now seeing this wouldn't mean a performance improvement as it only continues after 8s and doesn't wait for 8s. I reckon it's still good to have this change though just to prevent some potential edge cases.

Actually now seeing again this might be a performance improvement because it would simply say "not finished" yet if it thinks the process hasn't started yet. Only after 8s then it would declare it as finished

Description:

Please include a description of this change and which issue it fixes. If no issue exists yet please include context and what problem it solves.

Review

  • Functional review done
  • Usability review done (is anything maybe unclear or think about anything that would cause people to reach out to support)
  • Security review done see checklist
  • Code review done
  • Tests were added if useful/possible
  • Reviewed for breaking changes
  • Developer changelog updated if needed
  • Documentation added if needed
  • Existing documentation updated if needed

This can potentially bring a performance improvement as I think sometimes the system would wait for 8 seconds before declaring a process as finished even if it finished after 1s.

What happens is in https://github.com/matomo-org/matomo/blob/4.0.5/core/CliMulti.php#L217-L222 it checks if the process has started by checking if the PID file exists.

However, the `RequestCommand` deletes the PID file as soon as the process finished to signal "it finished". That means when we check in that loop whether the process has started, it would think it hasn't started yet and simply continue until 8s have past and then it would set the process as finished. Vs we can simply remember that once we say once "the process has started" flag then we can always remember this.

I would assume this race condition would happen constantly unless I'm not seeing it right.
@tsteur tsteur added the Needs Review PRs that need a code review label Dec 14, 2020
@tsteur tsteur added this to the 4.1.0 milestone Dec 14, 2020
@diosmosis diosmosis merged commit d83cd29 into 4.x-dev Dec 15, 2020
@diosmosis diosmosis deleted the processstarteddetection branch December 15, 2020 03:51
@mattab mattab changed the title Remember if process ever started core:archive Remember if process ever started Dec 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Review PRs that need a code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants