-
-
Notifications
You must be signed in to change notification settings - Fork 258
Open
Description
Problem
File indexing crashes with "Allowed memory size exhausted" when processing more than a few files. In our case, indexing fails at around 2-3 files with the default 256M memory limit.
After investigating, I found that Indexer::getIsMergingEnabledFormItem() calls getSolrConfiguration() for every single file being indexed. This loads and parses the entire TypoScript configuration tree each time, which in our setup consumes ~330MB per file. Only to determine whether or not file duplicates should be merged.
The configuration value being retrieved is the same for all files from the same site, but there's no caching.
Current code (line ~262)
protected function getIsMergingEnabledFormItem(Item $item)
{
$configuration = $item->getContext()->getSite()->getSolrConfiguration();
$merge = $configuration->getValueByPathOrDefaultValue('plugin.tx_solr.index.enableFileIndexing.mergeDuplicates', false);
return filter_var($merge, FILTER_VALIDATE_BOOLEAN);
}Proposed fix
Cache the configuration value per site:
private array $mergeConfigCache = [];
protected function getIsMergingEnabledFormItem(Item $item)
{
$siteRootPageId = $item->getContext()->getSite()->getRootPageId();
if (isset($this->mergeConfigCache[$siteRootPageId])) {
return $this->mergeConfigCache[$siteRootPageId];
}
$configuration = $item->getContext()->getSite()->getSolrConfiguration();
$merge = $configuration->getValueByPathOrDefaultValue('plugin.tx_solr.index.enableFileIndexing.mergeDuplicates', false);
$this->mergeConfigCache[$siteRootPageId] = filter_var($merge, FILTER_VALIDATE_BOOLEAN);
return $this->mergeConfigCache[$siteRootPageId];
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels