Problem/Motivation
Since we completed the move from PECL YAML library to Symfony YAML in https://www.drupal.org/project/drupal/issues/3205480 we have noticed that importing config takes considerably longer.
In testing we have found a config that took ~30 mins in Drupal 10.2 takes over 2 hours in 10.3.
Steps to reproduce
Import a large config file using drush sync:import
Here is the difference in time spent by each of these parsers when importing a 34M config.yaml


Proposed resolution
Allow the option to revert back to the older + faster PECL php parser - possibly via a config or settings.php setting
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | Screenshot 2024-11-07 at 15.40.33.png | 19.68 KB | rsaddington |
| Screenshot 2024-11-07 at 15.39.16.png | 47.59 KB | rsaddington |
Issue fork drupal-3486183
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
rsaddington commentedComment #3
rsaddington commentedComment #4
rsaddington commentedComment #5
rsaddington commentedComment #6
mglamanIt is, but not easily.
The hard part is:
The class must implement the \Drupal\Component\Serialization\SerializationInterface interface.Comment #7
cilefen commented30 minutes sounds impossibly slow to me also! How large is the configuration you are testing with?
Comment #8
rsaddington commentedThanks mglaman,
I assume the PHP PECL Parser does not implement this class and so using that is not possible without a patch/update to this project https://github.com/php/pecl-file_formats-yaml and then rollout to the hosting platform?
Comment #9
marcelovaniSee https://www.drupal.org/node/3415489
Comment #10
marcelovaniI was wondering if it would be possible reinstate the original \Drupal\Component\Serialization\Yaml class, create a new service to decorate the current class. Basically, swap it.
See core.services.yml
Comment #11
longwaveThere is discussion to bring back the
yaml_parser_classsetting which would let you change this again: #3485296: Regression: Deprecation of `yaml_parser_class` setting in 10.3 breaks sites < 11.0However, we removed support for PECL because it does not support arbitrary application specific tags at parse time; all possible tags need to be declared in advance, but the Symfony parser does not need this. See #3108309-26: Support Yaml::PARSE_CUSTOM_TAGS in \Drupal\Component\Serialization\YamlSymfony::decode for discussion.
Comment #12
longwaveAdding related issue.
Comment #13
alexpottThe question here should be what config read is not cached by FileCache?
Also are we talking about parsing a single 34 MB file or 34 MB of files? Also does the server have APCu installed - if not you'll get a massive performance boost by installing this.
Comment #14
cilefen commentedAPCu is not always enabled by default on the CLI, if that is the use-case.
Comment #15
catchAPCu is not only not always enabled on the cli but it's not shared between cli processes so it'll have a very low or zero hit rate for something like config import.
Ran into the same issue on #3478621: Add filecache to OOP hook attribute parsing and I've opened #3486503: Add a persistent cache for file-based discovery based on FileCache to see if we can make it more robust.
Comment #16
nilesh chhantbar commentedWorkaround: Fix of the issue https://www.drupal.org/project/drupal/issues/3485296 released in >= 10.3.8 and < 11 version allow to set $settings['yaml_parser_class'] = "YamlParserClass"; in settings.php. This is deprecated in >=10.3.X version and will be removed from 11.
Comment #17
alexpott@nilesh chhantbar that's not a fix for this issue - it's a delay of the problem till 11.x
Comment #18
nilesh chhantbar commented@alexpott Yes, it's an option or workaround until 11.x. It's clear that we need a solid fix in 11.x. or the upcoming release of 10.X.
Comment #19
holo96 commentedAm I right that as soon as #2951046 Allow parsing and writing PHP constants and enums in YAML files hits we can basically move this issue to "Closed (won't fix)"?
As performance enthusiast, I would choose performance here.
Also, implementing #2951046 issue means we are basically no longer using neither of YAML 1.1 or 1.2 standard
Comment #20
alexpott@holo96 yes.
I like performance too. But looking but any yaml parsing shouldn't really be a performance consideration. We should not be reading yaml as part of the live running of the site and we should minimise it on rebuilds to with file caching.
Comment #21
catchI still think we need #3486503: Add a persistent cache for file-based discovery based on FileCache so that cli rebuilds actually get a file cache hit (apcu, even if if it's enabled on cli, has a cache per-process), although it needs to be a completely new service rather than the current approach in the MR in there.
Comment #22
andypostAnother problem with PECL yaml parser is incompatibility with PHP 8.5 (NULL cannot be and array key but spec allows
~) and no viable perspective to support 1.2 spec.So +1 to close as designed
Comment #23
neclimdulI'll reach out to the developed, he's been quick to fix for new versions of PHP when contacted.
Comment #24
andypostFiled upstream issue https://github.com/php/pecl-file_formats-yaml/issues/97