Skip to content

Commit d2f36ec

Browse files
committed
[TASK] Wire parallel parsing and rendering handlers
Enable full pipeline parallelization by tagging the parallel handlers: - ParallelParseDirectoryHandler: replaces ParseDirectoryHandler for parallel file parsing using pcntl_fork - ForkingRenderer: replaces HTML TypeRenderer for parallel document rendering using pcntl_fork with copy-on-write memory Both handlers use MIN_DOCS_FOR_PARALLEL=10 threshold and auto-detect CPU count (capped at 8 workers). Also fixes FileAttributes array access in ParallelParseDirectoryHandler (use $item['basename'] instead of $item->path()).
1 parent b492eb5 commit d2f36ec

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

packages/typo3-guides-extension/resources/config/typo3-guides.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
use phpDocumentor\Guides\Compiler\NodeTransformers\NodeTransformerFactory;
3131
use phpDocumentor\Guides\FileCollector;
3232
use phpDocumentor\Guides\Handlers\CompileDocumentsCommand;
33+
use phpDocumentor\Guides\Handlers\ParseDirectoryCommand;
3334

3435
use function Symfony\Component\DependencyInjection\Loader\Configurator\inline_service;
3536
use function Symfony\Component\DependencyInjection\Loader\Configurator\param;
@@ -117,6 +118,7 @@
117118
->arg('$commandBus', service('League\Tactician\CommandBus'))
118119
->arg('$eventDispatcher', service('Psr\EventDispatcher\EventDispatcherInterface'))
119120
->arg('$logger', service('Psr\Log\LoggerInterface')->nullOnInvalid())
121+
->tag('phpdoc.guides.command', ['command' => ParseDirectoryCommand::class])
120122

121123
// Parallel Rendering - Document navigation for forked processes
122124
// Singleton that stores pre-computed prev/next relationships for use in child processes
@@ -131,10 +133,18 @@
131133
->arg('$logger', service('Psr\Log\LoggerInterface')->nullOnInvalid())
132134

133135
// Parallel Rendering - pcntl_fork based renderer for cold builds
136+
// Replaces the default HTML TypeRenderer for parallel rendering
134137
->set(ForkingRenderer::class)
135138
->arg('$commandBus', service('League\Tactician\CommandBus'))
136139
->arg('$navigationProvider', service(DocumentNavigationProvider::class))
137140
->arg('$logger', service('Psr\Log\LoggerInterface')->nullOnInvalid())
141+
->tag(
142+
'phpdoc.renderer.typerenderer',
143+
[
144+
'noderender_tag' => 'phpdoc.guides.noderenderer.html',
145+
'format' => 'html',
146+
],
147+
)
138148

139149
// Parallel Compilation Infrastructure
140150
// The ParallelCompiler uses pcntl_fork for parallel compilation. Currently

packages/typo3-guides-extension/src/Parser/ParallelParseDirectoryHandler.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,9 +310,11 @@ private function getDirectoryIndexFile(ParseDirectoryCommand $command): string
310310

311311
$contentFromFilesystem = $filesystem->listContents($directory);
312312
$hashedContentFromFilesystem = [];
313-
/** @var \League\Flysystem\StorageAttributes $itemFromFilesystem */
313+
/** @var \ArrayAccess<string, mixed> $itemFromFilesystem */
314314
foreach ($contentFromFilesystem as $itemFromFilesystem) {
315-
$basename = basename($itemFromFilesystem->path());
315+
// Use array access as phpDocumentor's FileAttributes wrapper supports it
316+
/** @var string $basename */
317+
$basename = $itemFromFilesystem['basename'];
316318
$hashedContentFromFilesystem[$basename] = true;
317319
}
318320

0 commit comments

Comments
 (0)