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 Avoid filesystem checks when process was set as finished #16954

Merged
merged 1 commit into from Dec 15, 2020

Conversation

tsteur
Copy link
Member

@tsteur tsteur commented Dec 14, 2020

Description:

Because in CliMulti we might check in a loop for every process constantly if they are finished. It won't help all that much but better to not check every time the file system when it is not needed.

There be many other things we could improve there. Will add some comments but probably best not to do them (or we'll see if it's needed later)

Technically, we could also set $this->started=true and avoid filesystem checks when startProcess() is called but shouldn't be needed at least in current code usage. It wouldn't really avoid any file system checks so far and would make it only harder to find some bugs maybe as the filesystem be avoided in the tests potentially.

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

Because in CliMulti we might check in a loop for every process constantly if they are finished. It won't help all that much but better to not check every time the file system when it is not needed.

There be many other things we could improve there. Will add some comments but probably best not to do them (or we'll see if it's needed later)
@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
@@ -129,6 +134,7 @@ private function pidFileSizeIsNormal()

public function finishProcess()
{
$this->finished = true;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

technically, once finished, we wouldn't need to call deleteFileIfExists again but we're ignoring this for now just in case for some reason the file was not correctly removed. Could add this check though. finishProcess could be called twice for example during regular job and when climulti:cleanup() is called.

@@ -81,6 +82,10 @@ public function hasStarted($content = null)

public function hasFinished()
{
if ($this->finished) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

technically, I was thinking we should check also if the process hasStarted() and when not has started not declare it as finished. It might be good to eventually do that especially once https://github.com/matomo-org/matomo/pull/16950/files is merged and we then remember if it ever started. The only problem be if a process starts and finishes too quick as part of climulti and then we might not detect the start and therefore don't declare it as finished and then climulti would wait for 8s to declare it as finished but this could happen anyway I suppose https://github.com/matomo-org/matomo/blob/4.0.5/core/CliMulti.php#L217-L222.

I might add this in a separate PR.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To get around the process quickly starts & finishes issue, we could avoid deleting pid files, and maybe delete them in a task. We'd have to include a timestamp somewhere, though..

I'm not sure how much of a problem it is re archiving though, since those jobs should take a bit to start.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think it's not really an issue and it be rare. Currently, the deletion of the pid file indicates a finished process but we can see. It shouldn't be needed for now I think (I think the method isn't even really called or so unless the process has started etc). I'll see if our issues are fixed with all these changes applied and if not investigate further

@diosmosis diosmosis merged commit 8c73d92 into 4.x-dev Dec 15, 2020
@diosmosis diosmosis deleted the finishprocess branch December 15, 2020 03:49
@mattab mattab changed the title Avoid filesystem checks when process was set as finished core:archive Avoid filesystem checks when process was set as finished 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