Skip to content

Commit

Permalink
FEATURE: improve performance for publish / discard workspaces
Browse files Browse the repository at this point in the history
... this ensures that during publishing of nodes, we do not fork
sub-processes for event processing (for every event). This speeds
up the system usually by at least factor 2-3 during these operations.

It *could* have some side-effects if caches were not properly cleared,
but at least I did not see any yet (and we run tests often with this flag).

Resolves: neos/neos-development-collection#4285
  • Loading branch information
skurfuerst committed May 16, 2023
1 parent e549e41 commit 6f2d5b7
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 22 deletions.
33 changes: 21 additions & 12 deletions Classes/Controller/BackendServiceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints;
use Neos\ContentRepository\Core\SharedModel\Exception\NodeAggregateCurrentlyDoesNotExist;
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
use Neos\ContentRepositoryRegistry\Factory\ProjectionCatchUpTrigger\CatchUpTriggerWithSynchronousOption;
use Neos\Eel\FlowQuery\FlowQuery;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Mvc\ActionRequest;
Expand Down Expand Up @@ -235,12 +236,16 @@ public function publishAction(array $nodeContextPaths, string $targetWorkspaceNa
);
}
try {
$contentRepository->handle(
PublishIndividualNodesFromWorkspace::create(
$workspaceName,
NodeIdsToPublishOrDiscard::create(...$nodeIdentifiersToPublish)
)
)->block();
// performance speedup
CatchUpTriggerWithSynchronousOption::synchronously(fn() =>
$contentRepository->handle(
PublishIndividualNodesFromWorkspace::create(
$workspaceName,
NodeIdsToPublishOrDiscard::create(...$nodeIdentifiersToPublish)
)
)->block()
);

} catch (NodeAggregateCurrentlyDoesNotExist $e) {
throw new NodeAggregateCurrentlyDoesNotExist(
'Node could not be published, probably because of a missing parentNode. Please check that the parentNode has been published.',
Expand Down Expand Up @@ -294,12 +299,16 @@ public function discardAction(array $nodeContextPaths): void
$nodeAddress->dimensionSpacePoint
);
}
$contentRepository->handle(
DiscardIndividualNodesFromWorkspace::create(
$workspaceName,
NodeIdsToPublishOrDiscard::create(...$nodeIdentifiersToDiscard)
)
)->block();

// performance speedup
CatchUpTriggerWithSynchronousOption::synchronously(fn() =>
$contentRepository->handle(
DiscardIndividualNodesFromWorkspace::create(
$workspaceName,
NodeIdsToPublishOrDiscard::create(...$nodeIdentifiersToDiscard)
)
)->block()
);

$success = new Success();
$success->setMessage(sprintf('Discarded %d node(s).', count($nodeContextPaths)));
Expand Down
27 changes: 17 additions & 10 deletions Classes/Service/PublishingService.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Neos\ContentRepository\Core\Feature\WorkspacePublication\Command\PublishWorkspace;
use Neos\ContentRepository\Core\Feature\WorkspaceRebase\Command\RebaseWorkspace;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;
use Neos\ContentRepositoryRegistry\Factory\ProjectionCatchUpTrigger\CatchUpTriggerWithSynchronousOption;
use Neos\Flow\Annotations as Flow;

/**
Expand All @@ -31,16 +32,22 @@ class PublishingService
public function publishWorkspace(ContentRepository $contentRepository, WorkspaceName $workspaceName): void
{
// TODO: only rebase if necessary!
$contentRepository->handle(
RebaseWorkspace::create(
$workspaceName
)
)->block();
// performance speedup
CatchUpTriggerWithSynchronousOption::synchronously(fn() =>
$contentRepository->handle(
RebaseWorkspace::create(
$workspaceName
)
)->block()
);

$contentRepository->handle(
new PublishWorkspace(
$workspaceName
)
)->block();
// performance speedup
CatchUpTriggerWithSynchronousOption::synchronously(fn() =>
$contentRepository->handle(
new PublishWorkspace(
$workspaceName
)
)->block()
);
}
}

0 comments on commit 6f2d5b7

Please sign in to comment.