Drupal Version
drupal 10.1.6
Domain module version
domain 2.0.x-dev
Expected Behavior
I would like to activate the domain scource module, but after activating the module, the contents are not available on the site.
Actual Behavior
PHP message: PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 262144 bytes) in /core/lib/Drupal.php on line 554; PHP message: PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 262144 bytes) in Unknown on line 0; PHP message:
PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 262144 bytes) in Unknown on line 0; PHP message: PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 262144 bytes) in Unknown on line 0, referer: /admin/content
PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 20480 bytes) in /core/lib/Drupal/Core/TypedData/DataDefinition.php on line 263; PHP message: PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 20480 bytes) in /web/core/lib/Drupal/Core/Session/SessionHandler.php on line 79; PHP message:
PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 20480 bytes) in /core/includes/errors.inc on line 26, referer: /admin/content
PHP Fatal error: Allowed memory size of 2147483648 bytes exhausted (tried to allocate 20480 bytes) in /core/lib/Drupal/Core/Cache/DatabaseBackend.php on line 172'
PHP Fatal error: Allowed memory size of 2147483648 bytes exhausted (tried to allocate 20480 bytes) in /core/lib/Drupal/Core/Cache/Cache.php on line 30'
Steps to reproduce
There is a lot of content on the site, hundreds. After I turn on the Domain source module, the page completely crashes.
| Comment | File | Size | Author |
|---|---|---|---|
| #16 | domain-source.patch | 1.14 KB | andy_w |
Issue fork domain-3402534
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
intradavid commentedComment #3
intradavid commentedComment #4
mably commentedLots of links on your pages?
DomainSourcePathProcessor service is rather resource hungry for example.
It easily takes 100MB of memory to process some pages on some of our sites.
Profiling using XHProf shows that rendering links can take more than 60% of total processing time, amazing.
We also have DomainEntitySourcePathProcessor service activated for handling taxonomies, so that doesn't help ;)
Comment #5
intradavid commentedYes, there are quite a lot of links on the page, what is the solution to make it work?
path_alias = 291,340
Comment #6
mably commented291,340 is that the number of links you are trying to display on a single page?
As I said above, we are displaying something like 1150 links on our home page and the request already takes about 100MB of memory...
Have you tried reducing the number of links displayed? Increase the available memory?
Comment #7
intradavid commentedNo, these are all the URLs used by the site.
Interestingly, the same problem occurs even if I just want to edit a content.
Basically, there is no problem, only after I turn on the Domian source module, I can't view or edit any single content.
+ If i want to add node same.
PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 16384 bytes) in /core/lib/Drupal/Core/Database/StatementWrapperIterator.php on line 110; PHP message: PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 20480 bytes) in /core/modules/mysql/src/Driver/Database/mysql/ExceptionHandler.php on line 46; PHP message: PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 20480 bytes) in /core/includes/errors.inc on line 26, referer: /node/add
Comment #8
intradavid commented/modules/contrib/domain/domain_source/src/HttpKernel/DomainSourcePathProcessor.php
This line eating my memory, when remove all working fine.
$url = Url::fromUserInput($alias, $options);
Comment #9
mably commented@intradavid, that's definitely the hotspot we identified on our side too, so we override this service to filter out the urls we don't want to analyze.
It would definitely be interesting to be able to filter out some url patterns, for our use case at least.
Comment #10
intradavid commentedmably, How can I help you solve this?
Comment #11
agentrickardHousekeeping first.
* Support requests are never flagged as "Needs review" -- that is reserved for patches or merge requests.
* When you comment out
$url = Url::fromUserInput($alias, $options);, nothing will happen. Its like uninstalling the module.I think the root question here is *why* are so many links being generated on a page?
If these were mostly admin links (such as from Admin Toolbar), we could pretty easily exclude those.
@intradavid -- from a testing perspective against a standard Drupal install, Devel Generate could easily create 300,000 nodes with aliases (though that might take a while).
From a development perspective, it would be ideal if we could cache this data -- the problem being that the cache object in this case would be too large to handle.
Comment #12
mably commentedHi @agentrickard,
It would definitely bring a nice performance improvement on some of our sites as we make an extensive use of Admin Toolbar and have sometimes more than 400 admin links.
Comment #13
agentrickardI would think we can make that a setting -- or a default behavior if there are no implementations of hook_domain_source_path().
Probably the best approach is a deny list that is editable, similar to the path settings for blocks.
We have a model for that in domain_config_ui/src/Form/SettingsForm.php -- a new issue to address that would be ideal.
----
Back to the original issue: two more questions:
1) What version of Drupal?
2) What is the memory limit current set to? (You can see this at admin/reports/status) -- and do you have the ability to change it?
Comment #14
intradavid commentedHi @agentrickard,
1) What version of Drupal? - Drupal core 10.1.6
2) What is the memory limit current set to? - 256M, 512M, 2GB tested, and last time database crash on the server.
Plus info:
- Devel module can creat new node.
Comment #15
agentrickardThanks. So let's go back to the original 3 questions:
Comment #16
andy_w commentedWe found the use of fromUserInput and getPathByAlias to be the source of the performance issue, and wondered whether there would be a benefit in making use of some of the other data available in the options, i.e. potentially the entity itself or the href as the first line of defence.
Comment #18
mably commentedLooks like the MR needs a rebase.
Comment #19
mably commentedI will close this issue in favor of issue #3232343: DomainSourcePathProcessor is resource intensive.
In my point of view, the current best solution in this case is probably to apply the patch from Core issue #3202329 and then either the corresponding patch from issue #3232343 or MR 177 from issue #3271978.
They both implement some of the improvements suggested in this thread.