Problem/Motivation
We should be defaulting to the PECL Yaml component if it is available as opposed to Symfony's because:
it is a performance improvement for reads (decoding)
and is YAML complient.
(Also, see #249)
We had originally talked about this way back in the beginning but it had been forgotten about.

Proposed resolution
Add a YAML class that decides whether to use the extension or Symfony. There's no point in using plugins and plugins are too heavy for this -- it's not extensible.
Also, Created Symfony issue for their invalid parsing: https://github.com/symfony/symfony/issues/16234
They seem to be aligning themselves with PECL as well:
http://symfony.com/blog/new-in-symfony-3-1-yaml-deprecations
API changes
Config save no longer throws exceptions if the config object contains an object or resource. While we could make Symfony do this, yaml_emity() doesn't do this so we can't make this a requirement.
Beta phase evaluation
| Issue category | Task|Bug because it is a performance improvement |
|---|---|
| Issue priority | Major, because it saves actually something |
| Unfrozen changes | No |
| Prioritized changes | Yes, performance improvements |
| Disruption | None |
Major, no disruption, performance improvement so allowed.
| Comment | File | Size | Author |
|---|---|---|---|
| #325 | add_a_drupal_yaml-1920902-325.interdiff.txt | 1.72 KB | neclimdul |
| #325 | add_a_drupal_yaml-1920902-325.patch | 62.15 KB | neclimdul |
| #211 | pecl-YAML-profile.png | 40.45 KB | neclimdul |
Comments
Comment #1
cweagansSounds like a pretty easy Drupal wrapper to write. If the extension is available, parse the YAML with the PECL extension. If not, use Symfony's parser as a fallback.
Tagging.
Comment #2
msonnabaum commentedYes, lets.
It's faster, and all around better and more complete as it uses LibYAML.
Comment #3
sunI already looked into this some time ago. The primary reason for why I did not continue is:
http://www.php.net/manual/en/book.yaml.php uses http://pyyaml.org/wiki/LibYAML, which implements the YAML spec v1.1.
Symfony's Yaml component implements v1.2.
Comment #4
msonnabaum commentedComment #5
msonnabaum commentedSymfony's yaml component doesn't not implement the complete spec:
https://github.com/symfony/Yaml/blob/master/README.md#yaml-component
Quick example of where symfony falls down:
Comment #6
msonnabaum commentedComment #7
damien tournoud commentedIn my opinion, this belongs as a Pull Request to Symfony. We should not partially fork or abstract the Symfony components we are using.
Comment #8
msonnabaum commentedNo one is suggesting a fork, but there is nothing wrong with not exposing an external library as a public api within our framework.
Comment #9
damien tournoud commented@msonnabaum: there is also no reason to add an abstraction to a component that we are using precisely so as not to maintain it. As soon as you add an abstraction like that, you need to test the abstraction so as to make sure that every implementation works the same way. Do we really want to start having YAML test cases in core?
Comment #10
catchTagging.
It seems reasonable to do this upstream but I'm neutral on that - more interested in it happening than how.
Comment #11
msonnabaum commentedI agree it adds some complexity on our end, but I dont think it's a reasonable request for symfony to defer to the extension if available, that's something we'd need to do ourselves.
Comment #12
cweagansSee here: https://twitter.com/fabpot/status/303913791643594752
So this is a no-go for upstream contribution. Let's do it in core.
Comment #13
Crell commentedIf it was too much trouble for Symfony to silently swap PECL vs. userspace, why do we think it would be beneficial for us to do so?
Comment #14
cweagansPerformance?
Comment #15
Crell commentedAre we ever parsing YAML in a critical path? I thought we'd been careful to avoid that.
Comment #16
gddWe are not, even if #1793074: Convert .info files to YAML gets in I don't think that will make any real difference.
Comment #17
cweagansWe're talking about adding < 20 lines of code for eeking out a bit of extra speed. It doesn't hurt to add such a tiny wrapper, does it?
Comment #18
pounardAdding a wrapper will force us to have less capabilities in order to support multiple different backends. IMO Symfony's component is a good choice, and we should stick to it. The problem is that if both parser/writers have tiny differences, those tiny differences could be enought to make them non compatible between each other if we decide to do some kind advanced use of the Yaml format. Maintaining the wrapper for two backends could also become a maintainance nightmare. As Crell said, Yaml parsing should never be in a critical path, so performance doesn't really matter here, parsing Yaml is probably already fast enough for what we have to do with it.
Comment #19
sunI'd recommend to try it out before continuing to debate hypothetic meta.
There are only minor differences between the YAML 1.1 and 1.2 spec. Additionally, while Symfony implements the 1.2 spec, it does not actually support the full spec, but only a very small and basic subset of it. I studied that for some configuration system issues already.
Whether it makes sense ultimately depends on the performance of the php-yaml extension, as well as your filesystem's performance. The exact point where it will get interesting is when reading/parsing YAML files through the extension would be faster than a cache lookup. If you think about it, that's not too far stretched, so within the range of possibilities.
Comment #20
alexpottIf anyone wants to do some benchmarking here's some code to use the PECL extension.
Interesting making this patch has discovered that we have some invalid yaml in the default system.maintenance.yml file message value. PECL issues a PHP warning... symfony doesn't... both end up just assuming it's a string.
In running the Configuration test group there is not a lot of difference in timings but this is to be expected as config is cached in the database.
However if I make the following change to the CoreBundle remove the config cache...
Symfony takes: 1 min 41 sec
PECL takes: 1 min 37 sec
With config cache (PECL): 1 min 38 sec
With config cache (Symfony): 1 min 42 sec
I would say that these results are close enough to be almost the same :) so there is no dramatic speed up here.
Note that the YAML files written by Symfony and PECL are quite different but I have not found any issues switching after the files have been written... i.e. the parsers can read each others files.
PECL looks like this:
Symfony looks like this:
Comment #21
pounard3 to 5 seconds improvements on a complete test suite is not insignificant, but is not a real performance improvement considering this hurts only non critical paths. After reading a bit more what looks like both parsers in term of API, it's basically only read() and dump() methods, it would be easy to maintain such wrapper, so I don't really care about doing it or not, I think both solution (having a wrapper or not having a wrapper) suits well to the need.
Comment #22
catchRather than the test suite I'd probably go for profiling a page with lots of configuration objects on a cache miss.
When a site has a completely empty cache (drush cc all / memcache restart etc.), it won't be able to serve any pages at all until particular configuration files are parsed and cached (along with lots of other cached stuff like plugins, theme registry etc.).
If this process is sufficiently slow then you can end up hitting max clients in Apache and similar limits as requests keep coming in but can't be finished. YAML parsing is unlikely to be the worst candidate here (/me looks at plugin discovery sideways), but where there's genuine performance improvement to be had in those cases we should take them when we can get them. That code tends to be shocking for performance because "well it's cached anyway isn't it" - and it's precisely when you have empty caches that your site might fall over and have trouble getting back up again.
Another place it may or may not make a difference is the installer where we have to install default config for a lot of modules all in one go - remember that some distributions might have 150 modules + a load of default config specific to the profile.
Comment #23
sunAwesome, Alex!
Comment #24
pounard@#22 Agree cache rebuild scenario are the worst, but I don't think that file parsing will ever do the difference. Things such as menu rebuild, features rebuild, views cache rebuild are so much trouble for both CPU time and memory consuption that I don't think parsing 150 Yaml files will be significant among all that.
Comment #25
catchIf we use YAML for .info files, this'll also get run on the modules page - since that gets an uncached list of modules and metadata from their info files every time it's hit. Again what percentage of time that actually is I'm not sure (we'd need to profile the patch to find out).
Comment #26
berdirSee also #1851234: Slow yaml parsing slows down tests which load/save many config files (e.g. views), can probably close that one as a duplicate.
Comment #27
cweagansRerolling for info file change (so we can use the PECL wrapper for info file parsing too). Also opened #1942432: Use extension_loaded instead of function_exists to detect PHP extensions.
Comment #28
berdirWondering if this should be a service. Could use a factory which also allows to override it using settings(), similar to e.g. cache/keyValue/queue.
Also, \Drupal\Core\DependencyInjection\YamlFileLoader should now be considered as well.
Comment #29
dawehnerOne great thing about using a service would be that the determination of the available extensions can be done on compiletime.
Comment #30
alexpottAn interdiff of 27 proved impossible so attached is an interdiff based on my local commits.
Patch attached
On my laptop a minimal profile install is 3 seconds quicker using the PECL extension.
Comment #32
tim.plunkett#30: 1920902-pecl-yaml-29.patch queued for re-testing.
Comment #33
alexpottSome of our YAML couldn't be read by the PECL parser and the layout module had an interesting use of config's Filestorage...
Patch attached fixes this.
Comment #34
berdirNice clean-up. We use this to read the services.yml files on which services are defined, so that's not really an option I guess, as this is as low-level as it gets.
So +1 on this. I know that @alexpott is also working with @jthorson to install the extension on our testbots and there are some promising results.
Comment #35
berdirDid run the Node test group locally and got 5m24 vs 6min19 and my results are relatively stable (second run was only a few seconds apart). So this looks like a nice improvement.
Combined with the #2006434: [meta] Speed up web tests, it should even get faster, although the improvements can't simply be added of course, as that other patch removes a ton of yaml parsing that this is making faster. But it should still be save a bit per test run.
Comment #36
damien tournoud commentedAs I mentioned in #9, if we want to go this way, we need to add full tests of YAML parsing.
Comment #37
berdirAlso did a full test run, with a concurrency of 8, is 22m10 without this patch and 17m18 with. That's a nice improvement.
Comment #38
jthorson commentedFailed to apply due to new
use Symfony\Component\HttpFoundation\RedirectResponse;line added to common.inc within the patch context. Reroll below.Comment #40
claudiu.cristeaShouldn't this get also a requirements entry telling what engine is used for YAML parsing?
Comment #41
cweagansI'm not sure that's necessary. Since this is controlled by the availability of a PHP extension, I imagine one could just look at the phpinfo page to see if the yaml extension is available.
Comment #42
chx commented[#2027461: Make the YAML parser a service
Comment #43
jthorson commentedReroll fail. Hmmm ... I wonder if this core/lib/Drupal/Component/Yaml directory is important? :D
Comment #44
berdirComment #46
jthorson commentedJust another re-roll, not addressing the fail in #43.Disregard. Duplicate declaration.Comment #48
jthorson commentedUgh.
Comment #50
jthorson commentedNo longer works after todays static YAML changes.
PHP Fatal error: Call to undefined function theme() in /var/lib/drupaltestbot/sites/default/files/checkout/core/includes/install.core.inc on line 941Comment #51
berdirFun!
My patch defind the $yaml property as a static array to cache parsed files. You assign the Yaml class to the same and then access it in a non-static way.
That threw an E_STRICT very, very early. That goes into the error handler, that tries to do something with watchdog, accesses the module handler, that doesn't exist and it throws an exception. That exception is caught by the installer and then the installer tries to display it. However, theme.inc has not yet been loaded, so it dies with that Fatal Error.
Comment #52
jthorson commentedAdmittedly, my reroll was just a shot in the dark based on where the patch wasn't applying, as opposed to being based on any understanding of the code itself. ;)
Comment #53
jthorson commentedSome testbot results:
One of our 'fast' OSUOSL testbots (659) without libYaml:
- 58,149 pass(es) in 1 hour 8 min.
One of our 'slow' OSUOSL testbots (654) without libYaml:
- 58,052 pass(es) in 1 hour 7 min.
One of our 'slow' OSUOSL testbots (dev) with libYaml:
- 56,102 pass(es), 5 fail(s), and 4 exception(s) in 58 min 1 sec.
Looks like about a 15% improvement in the overall testing time.
Results for the libYAML dev bot can be found at https://qa.staging.devdrupal.org/pifr/test/558838
Comment #54
jthorson commentedlibYAML testbot errors:
Drupal\filter\Tests\FilterAdminTest:
Illegal offset type in isset or empty in ckeditor.admin.inc line 36: template_preprocess_ckeditor_settings_toolbar()(3 times)Drupal\system\Tests\Common\ParseInfoFileUnitTest:
^^^ in Pecl.php line 32 - Drupal\Component\Yaml\Pecl->parse()
Drupal\views\Tests\Handler\AreaEntityTest:
Comment #55
berdirRe-roll.
This should fix the failures.
However, these look like automatically written files, which indicates bugs in the symfony yaml dumper? Which again means, we need test coverage for them.
Also, WTH is entity_id: '!1' ?! ;)
Comment #56
berdirD-D-Doublepost!
Comment #57
jthorson commentedConfirmed that this passes on a testbot with libYAML installed, in 1 hour 15 seconds. Testing has shown a savings of 6-10 minutes over a testbot without libYAML.
Comment #58
alexpottGiven #36 and #9 I'm not sure this is worth as Damien is correct will be have to assert everything we expect from a YAML parser.
I've abstracted the Yaml changes as this definitely need to be done... #2031597: Weird YAML data
Comment #59
jibran55: 1920902-pecl-yaml-55.patch queued for re-testing.
Comment #61
chx commentedOnce this is done, we could do much better for testing than using libyaml, much better indeed. YAML parsing will be slow, of course, faster in C, but slow still. We could write a little PHP file which contains two functions: yaml_parse and yaml_emit. yaml_emit would just call the relevant Symfony functionality but yaml_parse would wrap it in apc_store / apc_fetch . A very handy key would be md5($input) (the pox on core's hash policy, this is not core). Then preload this wrapper with Apache php_value auto_prepend_file and Bob's your uncle: no more parsing, even across test runs.
Comment #62
chx commentedComment #63
chx commentedComment #64
chx commentedLet's see what we can do here.
Comment #65
chx commentedComment #67
chx commentedComment #68
podaroklooks good #67
Comment #69
damiankloip commentedWhy a static variable, and not an instance/class property?
Use parenthesis.
Comment #70
damiankloip commentedSpoke to chx on IRC, it's very late for him now :) so rerolling with those changes on his behalf.
Also did a cleanup pass of the docs.
Sorry to change back from the RTBC, but there were a few of these things that had to be fixed up :) I guess it was tested and works well though. For me the patch is functionally great.
Comment #71
damiankloip commentedOK, so files are attached but not here on the thread? :( wat?
Comment #72
damiankloip commentedLet's try these uploads once again.
Comment #73
podarokinterdiff looks good for me
back to RTBC
Comment #75
herom commentedthe last patch is green, so... back to rtbc per #73.
Comment #76
sunI wonder whether yaml_parse_file() would yield an additional performance improvement?
(not loading the raw document into memory?)
Shouldn't we specify an UTF-8 encoding + LN linebreaks here?
http://php.net/manual/en/function.yaml-emit.php
The additional arguments no longer exist on Yaml::dump().
PHP_INT_MAX was moved, but why not ,0,TRUE ?
Additionally, isn't the consuming code (+ tests?) catching some of the Symfony\Yaml exceptions and needs to be updated accordingly?
Hm, not really keen on removing tests.
Does this mean that we're not throwing exceptions on invalid data types anymore?
Can we retain some level of error handling?
Comment #77
msonnabaum commentedUsing the word "plugin" here for the yaml implementation is very confusing considering they aren't plugins. Maybe change it to implementation?
Comment #78
chx commentedg
I strongly suspect you'd gain very little -- after all yaml_parse_file needs to read the file. And read #61 on a significant test spedeup that using yaml_parse opens up.
Nope. Talk to the YAML extension people, there's nothing yaml_emit gives you.
Comment #79
damiankloip commentedMade those changes to the YAML implementation class, and replaced the word plugin with implementation.
Added back the addition parameters to YAML dump, it was only really the last one that was doing anything before. Not sure what to do about losing that test. I think that is ok tbh. If we make the changes to the testbots to use Pecl YAML, and it doesn't throw exceptions, not too sure what we can do about that.
Comment #80
sunThanks! Let's move forward here.
Comment #81
catchI think it's worth adding the hook_requirements() as suggested in #40, although getting the wording right might be tricky. Could be a follow-up, but we have similar for PECL image uploads iirc.
Are there any differences between the output of Symfony and PECL for the files that get written?
Comment #82
catchAlso at least major. Cache misses == runtime.
Comment #83
webchickThat sounds like a needs review/needs work. Splitting the difference. :)
Comment #84
alexpott@catch see #20 for differences between the output of PECL and Symfony's YAML dumpers.
Comment #85
damiankloip commentedI personally think we should do the hook_requirements stuff in a follow up. Doc related patches often end with perpetual bikeshedding etc...
It would be good to get this change in.
Comment #86
catchOpened #2157447: Add hook_requirements() for PECL YAML parser.
Would be nice if there was a formatting option for single vs. double quotes for strings. But if there isn't then I don't think that should hold this up since both are equally fine.
Back to RTBC.
Comment #87
damiankloip commentedThere is not an option for either to configure the formatting of string quotes, I'm afraid.
Comment #88
catchYeah the only real references I could find to the string quotes being different were comments in this issue :p
Comment #89
alexpottDo we feel that #9 and https://twitter.com/fabpot/status/303913791643594752 can be ignored? I'm not sure that we've even run the full test suite with the PECL library.
Comment #90
catchIf we're going to have YAML in the critical path (i.e. the production configuration storage), then we need to address the performance issue. I disagree with #8 that the handful of extra lines of code are a problem, that's a lot less code than we've added to solve other performance issues.
I'd expect the test suite to find issues and I'm not convinced we need explicit YAML testing beyond that (at least for initial commit), but yeah I don't know if anyone's actually run that and we shouldn't commit until that's been done and confirmed.
I'd be OK with not having it swappable/using PECL at all if we did https://drupal.org/project/config_db in core but that'd be a big change.
Comment #91
drupalshrek commentedInstead of
wouldn't it be possible to default to one (or the other) and allow the Drupal user in configuration to choose which one to use?
It seems, from reading the comments above, that the code to automatically select which is the best one to use is problematical, and indeed the question of which is the best YAML parser may change over time.
So, isn't it possible to have in Drupal configuration something like:
Comment #92
damiankloip commentedNot if you are storing those settings from the list in the configuration system. As you will need the config system to parse stuff to get the setting before choosing the parser :)
This could be an option in settings.php at best imo. That could be a followup.
Comment #93
catchYeah that has to be settings.php (which you can use to switch out services, or just D7 style switch using Settings). It's a good idea.
Comment #94
damiankloip commentedIndeed. Do you agree we should open a follow up to discuss that? But yes, I think just a $setting would work just fine here. As well as being pretty much the only option :)
We would probably just want to add that logic to the new Yaml factory class provided by this patch.
Comment #95
chx commentedGiven how little it takes to make this settings.php overrideable and given that I already have an idea of why we would want to do that, I am adding it.
Comment #97
chx commentedComment #98
sunAfter seeing another seemingly random setting name/value being introduced here, I just filed #2160705: settings.php setting names are inconsistent (and undocumented)
Comment #99
damiankloip commentedok, thanks for opening that. It's a worthy discussion to have :) We can add this to the list in that issue.
On that note, I think this issue is done.
Comment #100
xjm97: 1920902_97.patch queued for re-testing.
Comment #101
webchickNeither alexpott or myself are very hot on this because of #12 (this is always going to be code we have to maintain, because Symfony has rejected this approach), and also (for my part) because we really don't need more environment-specific reasons that testbot might fail but localhost might not.
However, catch seemed to think this would be important for run-time performance. Assigning accordingly.
Comment #102
catchThe amount of code to maintain here is minimal - entire patch is 13kb.
The main argument against this is that we could get into a situation where the YAML dumped/parsed between the PECL and Symfony parsers isn't compatible, since that'd mean corruption. I don't think this is at all likely, although I'd feel more comfortable if we had a test that dumped with one, read back with the other, then vice-versa.
YAML was originally rejected as a format in large part due to performance (see https://groups.drupal.org/node/167584, which includes xhprof results showing the PECL parser to at least ten times faster than Symfony's - 44ms vs. 2882ms to parse 500 files).
On real sites, we can expect hundreds of YAML files between fields, instances, display modes, views etc. - and those will all need to be parsed from the filesystem when the cache is empty. The difference between (for example) 30ms and 2 seconds in the critical path to serve any page at all in such a situation is significant - especially given all the other file system scanning and parsing we have with plugins etc., so I don't think there's an option but to go ahead with this.
However, leaving this open for a day or two more so we can discuss how feasible a parsing test is (obviously it'll only run on a system with the PECL extension installed, but presumably we'll want to add that to the bots for performance anyway), and in case Alex/webchick have any more comments.
Comment #103
webchickI think that extra test is a great idea and would go a long way toward making me more comfortable with this.
Comment #104
jibran97: 1920902_97.patch queued for re-testing.
Comment #105
larowlan97: 1920902_97.patch queued for re-testing.
Comment #107
larowlanReroll and adds requested tests.
Comment #108
berdirYeah, I don't think so :)
Comment #110
larowlanLarowlan--
Will fix in morning
Comment #111
alexpottFixed test class name and and the ability to skip the test if the Pecl Yaml extension is not installed as it obviously is not on the testbots.
Also added a test for YAML node anchors which has highlighted a difference between Symfony and Pecl. Pecl does not support dots in anchor names.
Works on both.
Only works in Symfony
This is very relevant for #1996238: Replace hook_library_info() by *.libraries.yml file which is making extension use of node anchors with dots in.
Comment #112
damiankloip commentedHere we are using function_exists but in the test we are using extension_loaded(), we should make these uniform.
This could just be one one line.
Comment #113
rcaracaus commentedPretty sure I rerolled it right according to instructions above
Comment #115
klonos...remember to hide old patches/files when uploading new ones ;)
Comment #116
sunRe-implemented as
Drupal\Core\Serialization\Yaml. -SerializationInterfaceconcept courtesy of #2190723: Add a KeyValueStore\FileStorage to replace e.g. ConfigStorageThe previous location in Component wasn't really appropriate, because we're adjusting both Yaml implementations to follow Drupal's coding standards, and the Yaml "factory" has a dependency on
Settings, which happens to live in Component right now, but is misplaced there.The new Yaml factory ensures that the implementation is only instantiated once per request. In particular for the PECL implementation, this means we're overriding PHP INI settings only once.
My goal for D8 is to make the following default serialization formats easily available to the entire application:
Drupal\Core\Serialization\Json(moved fromDrupal\Component\Utility\Json)Drupal\Core\Serialization\PhpSerializeDrupal\Core\Serialization\YamlDrupal\Core\Serialization\XmlSerializationInterfaceuses static methods to make these simple encoding/decoding helper functions available to any code. The classes can still be instantiated and can also be registered/injected as services, which I actually did in #2190723: Add a KeyValueStore\FileStorage to replace e.g. ConfigStorage, but intentionally left out of this patch here.I manually tested both implementations locally, and Drupal installs fine with both. (PECL is tremendously faster, of course.)
Comment #117
sunAs promised: Green. :-)
The PHPUnit test to cross-test the PECL vs. Symfony implementations is still contained. Some other classes are merely simplified, since they no longer need to instantiate an object.
Moving forward here would certainly help especially core developers who need to re-install and run rebuild.php very often.
Comment #118
damiankloip commentedI am fine with switching this to a static implementation. As the instances were being created before solely to call the encode/decode method. No state is really involved.
Does this really need to be a part of the interface? The file format and the actual serialization does not seem that useful to couple together IMO.
As you're in this file anyway, we could add some @covers
We will need to check about your proposed change of moving to Drupal\Core\Serialization\Json. As this will break any existing code.
Comment #119
sunI'm happy to remove the
getFileExtension()method from this patch, if you feel strongly about that, but we're going to need it later on anyway.Corrected unit test location + added @covers.
Comment #120
MixologicI rerolled against latest head.
Now that Yaml::decode returns a static, it was conflicting somehow with the parsedInfos array in the InfoParser class. xdebug was showing two parsedInfos arrays defined, so I rolled back the static modifiers in InfoParser.php and changed it back to the $this->parsedInfos methodology as it existed before #2188661: Extension System, Part II: ExtensionDiscovery was applied.
I ran /admin/modules on a fresh cache without pecl yaml installed and everything worked great. I then installed pecl yaml, and everything still worked. I did some comparisons before and after the patch on a freshly rebuilt cache and have attached the xhprof summary.
The interdiff is super chundery, cause I couldnt figure out how to get an interdiff on a reroll with merge conflicts, so I just diffed the diffs. hopefully its reviewable.
Comment #121
sunI'm not able to confirm the hiccups mentioned in #120.
Therefore, attaching a re-roll of #119 (merged 8.x).
Comment #122
MixologicI had a mergefail
none of the hiccups in 120 were valid.
Thanks for this, btw. This will really help the YAML performance, especially when developing/site building.
Comment #123
sunThanks for confirming, @Mixologic.
Any chance to move forward here? I think this patch is ready to be committed.
Comment #124
sunCreated #2208609: Move Json utility class into Drupal\Component\Serialization
Comment #125
damiankloip commentedI'm sorry but when you basically rewrite a patch. You start the review process again :)
Comment #126
sunCreated #2208633: Add a Yaml class to Drupal\Component\Serialization
Comment #127
alexpottThis patch can not be tested properly on testbot until the pecl yaml extension is installed. I think this patch will pass even though there are PHPUnit failures since the test will be skipped.
Also I think that we need to ensure all YAML files we create in core are equivalently decode-able...
Currently they are not...
Comment #128
alexpottI still agree with @DamZ in #9 this is exceptionally risky. The above evidence shows Symfony Yaml parser would write a value
Ywithout quotes and PECL would interpret this as bool. This means switching YAML parsers on an installed site looks impossible.Comment #129
alexpottHere is proof of our problems...
Comment #130
alexpottWith the patch in #129 we get the following fail:
Comment #131
MixologicYuk. So the difference between pecl and symfony is boolean mangling and some other subtle problems.
It seems to me that the main value of having the pecl module is of primary benefit to dev environments (module building, site building, cold caches) - environments where the 'critical path' is redefined.
Given that, I think that this should only be enabled by a settings.php configuration, and don't believe that there should be automatic use of the Pecl yaml if the extension is loaded (imagine some shared host that just happens to have it installed etc.).
If a user has configured settings.php to use the YamlPecl, but doesn't actually have the extension loaded, we should throw an exception.
Additionally, there is the issue of configuration exports. I suggest that YamlPecl extends the YamlSymphony class and override the decode method, and avoid yaml_emit altogether. The majority of the performance gain happens on the decode side, and that would eliminate the possiblity of conflicting exports going from dev to production, or packaged as part of a distribution.
Comment #132
berdirPosted some benchmarks when running tests in #2006434-22: [meta] Speed up web tests.
Comment #133
Mixologicyaml pecl and symfony pecl are different enough (pecl = 1.1 yaml, symfony = subset of 1.2 yaml) That mixing the two totally fails.
I just ran a fresh installation with each parser, enabled every module, exported the configs, stripped out the uuid fields, and ran a diff.
Needless to say, it's a mess. Im completely unable to import a pecl-yaml config into an install running symfony (it throws a Drupal\Core\Config\UnsupportedDataTypeConfigException: Invalid data type in config editor.editor.basic_html: Unable to parse at line 8 (near " items:").)
I wish there were a C/C++ version of libyaml that supported 1.2 and that *also* had a php wrapper around it.
As slow as the symfony php parser is, I think our best option here is to improve that upstream as best as we can. Either that or put in some very, very stark warnings that if you use pecl yaml, your entire infrastructure has to support it, from dev to prod, and even then stuff is likely to fail.
My earlier idea of just using pecl to decode won't work as whatever it misinterprets on the input side would still be incorrect on the output using the Symfony encoder.
I really wish we could somehow use this, as it's so much faster. :(
Comment #134
sunJust for completeness, merged/re-rolled this against HEAD.
Comment #135
jibranLet's test anyway.
Comment #138
pwolanin commentedI think this is really a non-starter unless we have a PHP implementation and PECL that support the same spec and pass the same tests.
Comment #139
yesct commentedI think #1907170: Very simple config files can't be read is related.
Comment #140
yesct commented[removed duplicate comment]
Comment #141
larowlanre-roll
Wondering if we can use http://php.net/manual/en/yaml.callbacks.parse.php to help with the boolean differences between 1.1 and 1.2 - bool is a tag.
1.2: http://www.yaml.org/spec/1.2/spec.html
1.1: http://yaml.org/type/bool.html
Comment #143
larowlanYes! we can use callbacks - have the Y/y/N/n fixed.
Also filed #2400769: Duplicate label key in views data schema (patch included here)
Next issue is the 'some/sort/of/hybrid/key/0' yaml keys in migrate yml files which throw an exception and the
- - entry in core/profiles/standard/config/install/editor.editor.full_html.yml
Plugging on
Comment #145
larowlanAlso found #2400771: Duplicate entry for user views data schema and #2400773: Remove empty text.data_types.schema.yml
Comment #146
larowlanFixes the - - editor issue.
Fixes some intentional 'invalid' yml
Fixes re-roll muck-up which resulted in fatals during test setup.
Includes three issues opened as indicated by #143 and #145
Should be just the migrate file issues left (at least for YamlTest phpunit tests)
Comment #147
larowlanActually, the migrate issues aren't the use of the single quotes, but the use of @ in the values.
Checking for that in the yaml spec.
Comment #148
larowlanIt looks like we're using @ for aliases?
Yaml Spec says we should be using * and &? http://www.yaml.org/spec/1.2/spec.html#id2786196 - and for 1.1 http://www.yaml.org/spec/1.1/#id899912 so does that mean the '@' is a Drupalism?
If so....we might just be able to make this work.
If anyone can point me to where the '@' stuff came from/is processed/etc that'd be great
Comment #150
larowlannvm, single quoting the lines with '@' works, now for the test fails.
Comment #151
larowlanquotes '@stuff' in migrate yml files and fixes test fails - but also starts using Drupal\Core\Serialization\Yaml over Drupal\Component\Serialization\Yaml (except in the context of components)

Comment #152
larowlanThis one swaps it in
Comment #153
larowlanOk ready for real reviews here - also what's involved in getting the yaml pecl component on testbots - to see how much of a performance boost this is for testing?
Comment #154
cilefen commented@ is from Symfony docs but I'm not sure it is canon http://symfony.com/doc/current/components/dependency_injection/advanced....
Comment #155
kim.pepperJust a few nitpicks:
Can we call this 'serializer' rather than 'instance'?
Are we losing some useful information here?
Comment #156
larowlanPersonally I think we should make editor module use something other than '-' to represent a spacer plugin and drop this hunk altogether
Comment #157
larowlan#155 1: fixed, 2: no, not really
Also fixed #156 by quoting the -
Comment #158
dawehnerout of scope?
I'm not familiar with error handlers, but its odd that you have to restore error handlers eon every call to them? Maybe document why this is needed.
Good old times, when settings used to be a component and we did not needed all that shizzle all over the place.
leftover debug :)
This change is fine, but in general it is super confusing that its not named views.field.user as well.
mh? Doesn't that cause a regression in config translation?
Comment #159
larowlan1 will fix
2 yeah this was from an earlier patch, seems pecl/yaml doesn't throw a catchable exception?
3 again from earlier patch, is there a better way now?
4 will fix
5, 6 they are duplicated in HEAD see linked issues - basically those keys are given a value twice in the yaml
Comment #160
larowlanFixes 158.1 and 4
Updates fix for user.views.schema.yml as per linked issue
Waiting for answers to questions about 2 and 3.
6 is fixed in HEAD
Comment #161
larowlanNote https://github.com/symfony/symfony/issues/13209
Comment #162
larowlanAdds comment for 158.2 - related issue is #1247666: Replace @function calls with try/catch ErrorException blocks
Need more info for 158.3 - @dawehner can you elaborate?
Comment #163
dawehnerWell, when Settings used to be part of \Drupal\Components you would not need to override various classes for settings specific overrides. All those overrides are sad, honestly.
Comment #164
larowlanAh, so that means nothing I can do about it here?
Sorry if I'm being dense.
Comment #165
larowlanComment #166
larowlanSo ready for reviews again - would love to get this in.
Comment #167
dawehnerAre we sure these are the only differences?
Comment #168
larowlanThere's a new test that checks all yml files in core. If you have pecl tank installed it's passing. We need it on the bots before this goes in.
Comment #169
berdirThere's more to yaml than meets the eye... erm, our config files ;)
Take this example:
Gives this:
It is compatible, both can parse both versions, but the default (?) output is different. Which will be very annoying if you have yaml extension on your servers but not locally, we use the yaml format to diff staging/active...
Another example, from https://github.com/symfony/symfony/pull/11976
Gives me:
Again, both parse both versions correctly as a (float) 1, but the yaml is different. What are we going to do about this?
Comment #170
larowlanI would propose that we don't do anything :) If you have a difference between your prod, dev and staging environments etc, then you have bigger problems. The 'works on my machine' debate etc.
Functionally they are the same right? It's just the human readable output and version control you're referring to right?
Comment #171
berdirStaging and production I agree, but having differences between local development systems and servers as far as php versions and extensions go is very common.
Depends whether you consider a configuration import that never shuts up about having changes to import functional or not ;) I would, and our tests think so too (As they verify that there are no changes after doing an import).
Also, consider a user case where a contrib module adds a revert functionality, by comparing the config you have with the default configuration somewhere in a module. Not all contrib developers will have the same environment. Extending on that, this will obviously also affect patches with default configuration for core and contrib.
Comment #172
catchWhat if we decoded then encoded the YAML for the diffs rather than using the raw file contents? That'd also take into account hand-edited files.
Comment #173
larowlanAlso, you can use settings.php to nominate to use symfony/yaml everywhere if it is an issue between your local dev/staging etc.
Comment #174
larowlanNote we can also utilize emit callbacks :
http://php.net/manual/en/yaml.callbacks.emit.php
Comment #175
larowlanEdit: no we can't - those are for objects only
Comment #176
larowlanpinged @jthorson to request a test bot with pecl/yaml.
Note to self: remind him at the weekend
Comment #179
hussainwebRerolling. One of the major conflicts was from #1907170: Very simple config files can't be read which, apart from changes to
\Drupal\Component\Serialization\Yaml, introduced a newYamlTest.phptoo. Instead of merging, I just changed the newYamlTest.phpin the patch toYamlPeclTest.phpas it really relies on the PECL extension to work (the test is skipped if the extension isn't present).Comment #182
neclimdulReroll.
Also, cleaned up some docs and updated and cleaned up some code.
Ran a quick install comparison. Super scientific and all.
Without:
d8install 52.39s user 1.13s system 85% cpu 1:02.37 total
d8install 53.45s user 1.49s system 85% cpu 1:04.57 total
d8install 51.69s user 1.01s system 84% cpu 1:02.25 total
With:
d8install 34.34s user 1.50s system 79% cpu 44.807 total
d8install 34.78s user 1.02s system 78% cpu 45.818 total
d8install 33.51s user 1.27s system 78% cpu 44.128 total
Comment #183
berdir50s.. I assume you either have xdebug and/or xhprof/uprofiler enabled?
Try without, On my system, the installer is almost twice as fast without xdebug.
Also, might be worth testing it with the file cache patch applied, my I guess is that the difference will be much smaller, because we only parse each yml file once instead of up to 40 times.
Comment #184
neclimdulxdebug is turned off. I do more then just drush si in that script though.
Comment #185
neclimdulnumbers without xdebug.
Without:
d8install 25.37s user 0.81s system 74% cpu 35.328 total
d8install 25.93s user 1.01s system 74% cpu 36.291 total
d8install 25.73s user 0.94s system 74% cpu 35.689 total
With:
d8install 15.92s user 0.84s system 68% cpu 24.595 total
d8install 18.43s user 0.84s system 67% cpu 28.353 total
d8install 16.81s user 0.88s system 66% cpu 26.582 total
So about 8 seconds which is actually a 33% decrease instead of 28% so a little bit better.
Comment #186
neclimdulNo more instantiation. Better unit tests. Fix a couple yml files that didn't parse right. Details in interdiff.
I'm pretty happy with where things are at this point.
Comment #187
neclimdulTurns out this found a bug in DrupalStandards listener. Since this breaks the phpunit test runner when the yaml extension is not installed this is sort of blocked until that is resolved.
Also, fix another yaml error. Based on the number of yaml changes in the patch, it seems Symfony's implementation has some quirks...
Comment #188
neclimdulreroll around conflict
Chx updated the migrate documentation so the changes in the patch are documented.
https://www.drupal.org/node/2135307/revisions/view/7082283/8298081
https://www.drupal.org/node/2135345/revisions/view/6924553/8298083
Comment #189
neclimdulString -> Safemarkup chuck collision.
Comment #190
neclimdulchuck collision. no changes.
Comment #192
neclimdulActually a little more then that. I ran unit tests before uploading this but got distracted and forgot to look at the results. #2470928: Versions in core.libraries.yml are not always parsed as strings fixes a lot of our YAML. However it adds some tests around dates that are tied to symfony's implementation of tag resolution.
Unfortunately this causes our "all of core parses the same in PECL and Symfony" test to fail. This is a bit annoying because we've built a test for the behavior of our yaml parser into a library test which is really "unit" testing.
I've been spent a good portion of this afternoon scouring both the 1.1 and 1.2 version of the spec and this line keeps getting in the way "Tag resolution is specific to the application". This rule specifically applies to complex types like timestamps which are discussed but not actively defined by the spec. I tried to turn on yaml.decode_timestamp which sounds like it would act the same way symfony's implementation does but it actually resolves more then really should including parsing quoted and "non-specific" tagged nodes.
I've opened up a bug report here: https://bugs.php.net/bug.php?id=69465 Its possible that the bug is the other way and the bare tag should be parsed without that ini setting... or they are both bugs... I'm not really sure. We can probably work around this similar to the way to what we did for bools but I haven't gotten to it.
Comment #193
neclimdulFix invalid YAML from #2389735: Core and base theme CSS files in libraries override theme CSS files with the same name
Remove library test because I can't figure out what its testing other then YAML parses like YAML. There is no specific functionality its testing in the Library code.
Clearly there's a bit of a "bug" in PECL's date parsing though. :-/
Comment #194
neclimdulreroll for another chunk collision
Comment #195
anavarres/Yaml/YAML
I'd suggest replacing the comment by: "Use the PECL YAML extension if it is available."
The closing brace for the class must have an empty line before it.
There should be a space after the closing parenthesis.
Maybe change the comment for something similar to "Use a settings.php override if any"
s/Yaml/YAML
Also "certain things" could probably use some more clarification.
Missing the @return comment on new line.
Missing a comma.
This function is missing doc comment.
Should this be s/Null/NULL?
I don't think 'Anchors' needs a capital 'A'.
This function is missing doc comment.
@group and @coversDefaultClass sections should be separated by a blank line.
The @coversDefaultClass and @requires sections should be separated by a blank line.
@covers and @dataProvider sections should be separated by a blank line.
Ditto.
Ditto.
Missing a full stop.
@covers and @expectedException sections should be separated by a blank line.
The closing brace for the class must have an empty line before it.
@group and @coversDefaultClass sections should be separated by a blank line.
@coversDefaultClass and @requires sections should be separated by a blank line.
Ditto.
Ditto.
Ditto.
The closing brace for the class must have an empty line before it.
s/on/one
s/TODO/todo
s/this/This
s/no/not
=> With those changes, the todo should be wrapped at 80 chars.
@requires and @dataProvider should be separated by a blank line.
s/files core/files in core?
There must be a blank line between the comment and the @return tag.
The @return tag is missing the return comment on new line.
The closing brace for the class must have an empty line before it.
class is missing its doc comment.
The function is missing its doc comment.
The closing brace for the class must have an empty line before it.
The class is missing its doc comment.
The functions are missing their doc comment.
Comment #196
neclimdulThanks, that's a really extensive review.
13-25,29) separated annotations
Spent 10min scrounging google, issues queues, and docs and couldn't find a standard on it and I've never done this in other tests I've written.
@return comments - I'd rather remove them then duplicate the method documentation.
33,34,36,37) This is standard for stub objects in tests.
Comment #198
neclimdul#$%^ simpletest....
Renamed abstract base test to work around weird "@group" test in simpletest discovery.
Comment #202
anavarreThanks!
IIRC, Coder sniffs will alert about that + I've seen it in core files quite frequently so assumed it's a best practice. Random example:
tests/Drupal/Tests/Core/Config/Entity/ConfigEntityStorageTest.php
Would love to have confirmation though.
Didn't know, thanks.
Comment #203
neclimdulReroll
Also I don't think I was really clear in my previous rushed response. By standard I meant common or de-facto rather then a documented standard. Documentation standards are considerably more lax in testing classes.
Comment #205
neclimdulRe-roll. Now that we have the new bots, will poke people to get yaml installed so the included tests aren't skipped and run.
Comment #207
neclimdulthing
Comment #209
neclimdulComment #210
neclimdulFigures I'd get a chunk conflict within hours of re-rolling this.
Comment #211
neclimdulShouldn't be any surprise but the cold cache profile is very good.
Comment #212
neclimdulReroll around the great migrate move of 2015
Comment #213
neclimdulthe real patch.
Comment #214
joelpittetAdding a Beta Evaluation using @dawehner's PR https://github.com/alexpott/dopatchutils/pull/13/files and putting it on the radar of #2470679: [meta] Identify necessary performance optimizations for common profiling scenarios
Comment #215
neclimdulTouching up beta eval. The blob of table tags can be hard to parse sometimes.
Comment #216
neclimdulComment #217
neclimdulI guess another re-roll...
Comment #219
neclimduldidn't merge #2490388: InfoParserUnitTest web test classes mislabeled as unit tests correctly and accidentally re-added the test and fixture.
Comment #220
neclimdulCouldn't find the drupalci issue for PECL YAML so filed one.
Comment #221
larowlananother reroll
Comment #222
dawehnerLooks pretty good for me. Not sure whether I'm feeling knowledgable enough, anyway
nitsuggestion: You could use ::class, just to make things a bit easier
is there any benefit from using a class static?
Comment #225
hussainwebIt was a straight reroll.
Comment #226
jibranBack to RTBC.
Comment #227
neclimduloh my! thanks guys!
#222.2 I honestly can't remember why its written like that at this point.
Comment #228
MixologicOkay, I have good news and bad news. The good news is that with pecl yaml installed on a testbot, and no other changes, everything passes. So we can go ahead and add this to all the testbots without worrying whether it will break things:
https://dispatcher.drupalci.org/job/DCI_XML/143/testReport/
https://dispatcher.drupalci.org/job/DCI_XML/143/consoleFull
I went ahead and ran an ad-hoc test with the patch in 225, and
it did give the testbots a good speed kick. Not *tons*, but significant:
without patch: Test run duration: 27 min 58 sec
with patch: Test run duration: 25 min 23 sec
The bad news is the tests didnt pass:
https://dispatcher.drupalci.org/job/DCI_XML/144/testReport/
https://dispatcher.drupalci.org/job/DCI_XML/144/consoleFull
For those phpunit tests that failed, I have more data from the bot itself.
and
Comment #229
neclimdulFixes for failures.
Comment #230
neclimdulself review:
This looks bad, its actually duplicate code and the two parsers are handling it differently. Seems someone was manually tinkering?
colon followed by white space is creating a mapping which isn't valid in this location. either quote or have something after it.
Comment #232
neclimdulHeh... i've had about enough of your antics pifr.
Comment #233
neclimdulclean merge reroll. use chunk conflict with #2451411: Add libraries-override to themes' *.info.yml.
Comment #234
fabianx commentedRTBC - This looks good to me, but we need to discuss the disruption for contrib.
Comment #237
neclimdulThanks mixologic for hacking drupalci so we can test this.
The ConfigDiffTest failure had trouble with pecl putting a "---" on the first line but that not matching the exports. String diffs versus data diffs. The diff arrays aren't convenient to work with but added a smarter(but pretty hacky) assertion wrapper that tests specific changes in the diff array.
The ConfigSimpleImportExportTest was similarly doing string matches. Converted this one to compare data though.
Standard installer test was asserting Symfony's array indenting. Both of these are valid and parse the same in both parsers but don't match the string match.
Comment #240
neclimdulchunk collision with #2487588: Move CMI import/export directory "staging" to "sync", as it is confused with staging environments . No changes.
Comment #241
joelpittetBack to RTBC
Comment #242
alexpottTicking some credit boxes @YesCT's request - I'm still not convinced this patch is a great idea for core. What might be a good idea is making it so that contrib can swap it out. Without having to swap everything out.
Comment #243
neclimdulIn my opinions the benefits far out weight any drawback and I've worked to make sure the tests are verbose and clear as you'll see. First, let me re-iterate some arguments for why this should be in core though.
The downside seems to be that testbot might throw errors that don't occur locally. Examples of failures that might show up in testbot:
String difference. These are the hardest. The difference are currently limited it seems to prefixing YAML with "---" and maybe some indention. They are a bit tricky to test but generally can by handled by parsing and comparing to a dataset. Since testing strings coming out of the YAML parser should be the domain of the YAML parser/emitter itself those sorts of test have a little bit of code smell anyways. If we _have_ to get the output closer it seems fair that we can address that in follow up.
Invalid YAML that worked in Symfony. I actually put some effort to make sure the error bubbles up through phpunit so its pretty clear. Edited core.services.yml to have an invalid tag, this was the output:
Something that parses differently. In my experience this is caused by Symfony using the first value of duplicates and PECL implementation using the second. The spec is weird and says there MUST not be duplicates but it also says implementation should be silent about parsing them and nothing else. Its implied it should match JSON parsing which I think makes PECL more correct but either way this is catching buggy YAML.
Edit: clarify #4 in benefits
Comment #244
fabianx commented+1 to getting this in.
The best way would have been to have a YAML 1.1 compatibility mode on the Symfony parser ...
Comment #245
yesct commentedwanted to summarize some discussion:
concern that if pecl is on a dev env, and not on prod (or the other way around)
then dev and prod sites that are otherwise the same, may differ.
we run into that same problem with, for example, people who have different php versions on dev and prod
people have been able to solve that, by writing env's down in revisionable code: like vagrant build scripts,
to make sure the environments are the same for dev and prod.
similar to the version of php, people would have to make sure it included (or did not include) the pecl yaml component.
so ensuring behavior consistent across envs is not a new problem, and has a solution.
Comment #246
neclimdulYeah, if you're developing on an environment that doesn't match your production there are any number of problems that can creep up. Just to re-iterate because this keeps coming up, this would only affect manually written YAML. Symfony correct escapes things when creating even if it allows invalid tags to be parsed.
Comment #247
neclimdulanother reroll... #2533800: Remove all unused use statements from core
Comment #248
neclimdulI'll claim trying to get this resolved in 8.0 for now.
Created Symfony issue for their invalid parsing: https://github.com/symfony/symfony/issues/16234
Created follow up to add contrib coding standards check: #2591827: Add YAML linting to core coding standards checks
Comment #249
alexpottDiscussed at length with @catch.
I think we can make this an RC target for the following reasons:
However in order to commit this patch during RC we need to make the following changes:
Comment #250
fabianx commented+1 to #249:
- I 100% agree that we use only Symfony to write
- In theory - if strict mode does not happen upstream - could we try re-reading the file with Symfony if PECL yaml parsing fails / throws an Exception?
Comment #251
neclimdulI've disagreed with not proxying the encode method in the past but lets just get this in. I'll leave the testing stuff to the testing group.
Comment #253
fabianx commented#251: Could you answer the question:
"- In theory - if strict mode does not happen upstream - could we try re-reading the file with Symfony if PECL yaml parsing fails / throws an Exception?"
Is that feasible - we could still alert via watchdog or an assertion or a trigger_error, but would not affect production sites.
Comment #254
dawehnerIt would be great to put some line there explaining why we want to use the same code always for writing.
Comment #255
neclimdulFix the brown bag error in the last patch.
- In theory - if strict mode does not happen upstream - could we try re-reading the file with Symfony if PECL yaml parsing fails / throws an Exception?The "strict mode" in the Symfony issue would only affect reading. None of the fixes that have come out of this issue seem to come from export code but from manual editing. So writing and then re-reading would not really help anything.
Someone else will have to write the line for why, I don't really know why we've decided to do it because writing differences have never been a problem in this issue.
Comment #256
fabianx commented#255: What I mean is regardless of any upstream changes:
- Given I manually edit a file
- Given it is read correctly by Symfony
- Given it fails on pecl
- When I install the pecl extension on production
- Then I expect Drupal to gracefully fail
- And read the file via Symfony
--
e.g.
decode:
That should alleviate alexpott's concerns.
Comment #257
neclimdulAs noted in the summary, yaml_emit() doesn't throw exceptions so no go with at least that implementation.
Honestly, if you're going to run different environments in productions and dev and not have any testing in between there's only so much we can do.
Comment #258
yesct commentedI'll take a stab at writing the comment, and also open the issue for the testing environment.
Comment #259
yesct commentedbut first just some nit fixes.
took out these unused use statements (not needed because they are in the same namespace)
I'm guessing this was copied from somewhere, but we dont use $file and $line.
looked at:
ag "function errorHandler"
for some examples and some dont have the file and line, so I think we can not have it here either.
broke this up into separate sentences, fixed grammar a bit, and used US english spelling (895 vs 23 usages).
put some changed uses in alphabetical order. (only in the lines changed by the file, so the interdiff shows changes in order, but the patch should be still all in scope)
expected can be a string or bool? but string is always a string?
Assert same would check the type also.
Just want to make sure that we want to do it like we are.
fixed some typos.
added an issue for this @todo. #2597730: Test should be an integration test and not a unit test for all YAML files being decoded in the same way with Symfony and PECL.
Comment #260
yesct commentedsays optimal, but doesn't list why it is better.
changed comment to:
"Determines which implementation to use ..."
but... it is not being used for encoding (writing) anymore. always writing with symfony.
so also changed it to "... for parsing YAML."
---
and tried to explain why we always use Symfony for writes (encoding).
Please look at this interdiff carefully.
Comment #261
yesct commentedmade the issue @alexpott asked for in #249
#2597762: Add a new testbot with (only) Symfony yaml parser (not the pecl one)
That blocks this issue, yes?
------
put the upstream issue in the issue summary.
I think I'm done for now. Unassigning.
Comment #262
yesct commentedI asked about the static methods in IRC (and looked up static http://php.net/manual/en/language.oop5.static.php )
neclimdul responded
Comment #263
neclimdul#2600686: Broken views test config YAML conflicted.
Comment #265
neclimdulman, sometimes I can't even roll a patch.
Comment #266
david_garcia commented+1. I've testing for a while now on our dev environments.
Just note that it helped discover broken Yaml's on some contrib because the PECL parser seems to be more strict - or at least does not behave 100% as the symfony parsers.
Comment #267
neclimdulThis and the tests it provides are now a bit more important. Drush changed its composer file so it now may be installing Symfony 3.0's Yaml component.
https://github.com/drush-ops/drush/pull/2003
Because of how autoloading works, this means when we have invalid YAML going forward, Drush will be broken.
Example: #2674198: @menu_name in menu_links migration_template is invalid yaml
Comment #268
neclimdulJust a reroll. NW because I don't know what the path forward is and #2674198 would cause it to fail.
Comment #269
neclimdulIn hindsight, the status didn't matter. the testbot issue is still open.
Comment #270
neclimdulJust updating since this would have to be applied to 8.2.x first. Still applies cleanly and does its thing. It looks like its being tested by testbot too as there are just shy of 2000 more assertions in the last test run when compared to the HEAD run on the same day.
Comment #271
MixologicComment #272
neclimdulreroll around conflicting changes from #2679883: Audit use of YAML to ensure we're not using deprecated syntax
Comment #273
neclimdul#272 still applies to 8.0 but #2686207: Convert simpletest kernel tests in modules A-I to phpunit broke this for 8.1.x and 8.2.x so here is the reroll.
Comment #274
neclimdulSorry user error. wrong parameters to my reroll script ends up with all the difference between 8.1 and 8.2 :(
Comment #275
xjmComment #276
xjmDiscussed with @neclimdul and marking for framework manager review for some visibility.
Comment #277
neclimdulreroll around #2665992: @file is not required for classes, interfaces and traits
Comment #278
joelpittetThey seem to be aligning themselves with PECL as well:
http://symfony.com/blog/new-in-symfony-3-1-yaml-deprecations
This to the issue summary
Comment #279
neclimdulIts that time again. Time for a conflict reroll.
#2380293: Properly inject services into ModuleInstaller shuffled/added some use imports so that chunk conflicted. no changes.
Comment #281
neclimdul#2721741: Fix double argument declaration in core.service.yml
Comment #282
neclimdulLets try that again.
Comment #283
neclimdulAny chance of getting that framework manager review?
Comment #284
jibranI read today in https://docs.google.com/document/d/1-_AgTnZu9e2iAuEpnp262mguFInNaiIcSxsM...
So setting it to RTBC.
Comment #286
neclimduluse statement conflict in moduleinstaller.
Comment #288
neclimdulwelcome to late night patch rerolls where I forget to diff off origin and make empty patches.
Comment #289
neclimdulNoticed the test wasn't catching a yaml file bug in my modules directory because the directory was one ../ off.
Comment #291
neclimdulI forgot we have a follow up for contrib. Rather then continuing to fix it I'll revert that change and make a patch there.
Marking RTBC because this is the same patch jibran RTBC'd with the exception of the use statement fixes.
Comment #292
jibran+1 for RTBC.
Comment #293
catchI haven't done an end-to-end review of the patch yet, but I like the approach in general. We use the PECL extension to read when we can, we use Symfony to write all the time so that things are always consistent that way.
While we have filecache and similar, those became necessary because YAML parsing is so slow, so improving the raw uncached performance still seems worth it to me.
Assigning to @alexpott since he had more concerns with this than me originally.
Comment #294
catchSpoke to @alexpott and all his objections are covered by writing with Symfony YAML always. So unassinging and removing framework manager review tag.
Comment #296
alexpottI wonder what has changed to cause the fail - the error looks related to the patch and not random.
Comment #297
MixologicNot related to the patch: related to php7 being on the bleeding edge of 7.x php branch: #2764687: IpAddressBlockingTest is failing on DrupalCI
Comment #298
neclimdulThat explains why I couldn't find anything with the couple hours I spent trying to track it down :) oh well, reverting status.
Comment #299
alexpottThis is the fail I was wondering about.
Comment #300
MixologicAha. I had to hunt around to find it: https://www.drupal.org/pift-ci-job/364955
Its strange that it doesnt fail now.
Comment #301
alexpottSo I think we need a change record that details the added support for the PECL YAML extension and it probably needs to explain the only unmitigated change (#111) - the fact that Drupal does not support dots in anchor names. Anchors are very very rarely used so I think this is acceptable.
Comment #302
alexpottComment #303
Crell commentedIn the change notice, please include the benefits of doing so, ie, whether you'd want to add that extension on production. (You know, for Drupal hosts... :-) )
Comment #304
alexpottSetting to 'needs work' for the CR.
Comment #305
neclimdulHaven't had any time to look at a CR but here's a quick reroll around #2627678: Specify view mode to be used by comment formatter.
Comment #306
MixologicComment #307
joelpittetStubbed a draft CR for you to all tweak
https://www.drupal.org/node/2769555
Comment #308
neclimdulreroll around #2473179: Use FileCache for config storage
Comment #310
catchThat looks like a real failure:
https://www.drupal.org/pift-ci-job/380935
Comment #311
neclimdulActually the fact that passes anywhere is weird. "Malformed inline YAML string" is from Symfony and that test is suppose to be testing that the error from the parser is triggered. For a different parser the proxied error is going to be slightly different. it should just assert "The import failed with the following message: "
Comment #312
neclimdulA big update of the patch to catch all the new inclusions of Yaml from Component since we've just been re-rolling for a while now. This should force the failure in in #310 because it was one of those locations. I've adjusted the test to assert the static part of the error which is just "The import failed with the following message: "
Comment #314
neclimdulbah... core/modules/rest/tests/fixtures/update/drupal-8.rest-rest_post_update_resource_granularity.php needs a binary diff. same patch with --binary. Interdiff would be the same with the addition of an unreadable binary hash for that file where Component is being changed to Core.
Comment #315
neclimdulUpdated the CR to contain more information.
Comment #316
Mixologici would RTBC, but IM unsure if #314 was supposed to pass or not.
Comment #317
jibranYeah #314 suppose to pass.
Comment #318
alexpott@neclimdul I still don't understand why the failure was random.
Comment #319
alexpottWhy does this exist? I.e. why are bypassing the file caching in
\Drupal\Component\Discovery\YamlDiscovery?This addition, and the related changes, do not seem necessary for the patch.
The change notice should tell people to swap out the component Yaml for the core Yaml to behave as expected.
This has the potential to cause contrib tests to fail - should be mentioned in the CR.
Is this actually a required change for this to work?
This has the potential to cause contrib tests to fail should be mentioned in the CR.
Comment #320
alexpottThis setting has no documentation and is untested.
Comment #321
neclimdul1) I think it was just written before FileCache existed. Refactored Component to allow decoding to be replaced so the Component FileCache logic can be used. Additionally made sure new uses of YamlDiscovery since this was written use the Core version now.
2) 3) 5) CR Updated. Additionally documented YamlDiscovery change from 1)
4) I think that was just fixed in a different issue and that's the artifact of a merge. " is more consistent with our other YAML files and I believe what will be output by both Serializers but ' isn't wrong. Reverted that block.
Test and documentation for setting in interdiff.
Comment #323
neclimdulgosh darn --binary...
Comment #324
alexpottI can't see if the testing part of #320 has been addressed?
Comment #325
neclimdulSeems I forgot to stage the new test file.
Comment #326
alexpottThanks for the test @neclimdul. Everything looks good now! Nice one.
I've reviewed and tested this patch extensively. The CR looks good - telling developers and site owners how this change impacts them. I've discussed this change with @catch and we agreed that whilst this does mean the developers should update their code to use the core classes, if they continue to use the component classes nothing with break, just the new setting won't work. This is an acceptable trade-off for the potential cold-cache performance benefits.
I've not being involved in any of the more recent code so I don't consider this my patch.
Comment #327
catchReally, really nice to be able to commit this one.
Committed a0a530f and pushed to 8.2.x. Thanks!
Comment #329
anavarreThanks for sticking to this issue for so long @neclimdul!
Comment #330
wim leersYes, incredible persistence, @neclimdul!
Comment #331
neclimdulThanks guys! Your kind words really recharge the old batteries after a long haul. :)
It takes a village though and you guys are a great one. A round of applause for the mountain of effort going on from everyone else because there where a ton of reviews, fixes and 2 years of effort before I even rolled a patch! :)
Comment #335
wim leersFYI: #2882708: Serialization\YamlTest test failure after doing `pecl install yaml-2.0.0`.