Page MenuHomePhabricator

Parsoid is OOMing on srwiktionary pages
Closed, ResolvedPublic

Description

We got reports about a spike in MediaWiki fatals (500s) as being due to Parsoid OOMing heavily on srwiktionary pages.

See https://grafana.wikimedia.org/d/000000438/mediawiki-alerts?panelId=2&fullscreen&orgId=1&var-datasource=eqiad%20prometheus%2Fops&from=now-12h&to=now

See https://logstash.wikimedia.org/goto/09804d4863788f4d7bec5dd672f6ebcd which is filtered on srwiktionary and enables OOMs and Timeouts. This shows that there has been a spike in srwiktionary

I picked one of the OOMing pages: https://sr.wiktionary.org/wiki/%E0%A4%9B%E0%A5%8D%E0%A4%B8 and parsed locally on my laptop.

time php bin/parse.php --domain sr.wiktionary.org --pageName 'छ्स' < /dev/null > /tmp/php.srwikt.out

This completed in 35s but resident memory usage spiked to about 2.4gb which is much over memory limits in production.

Just for kicks, I ran Parsoid/JS with time node bin/parse.js --trace time --dump wt2html:limits --domain sr.wiktionary.org --pageName 'छ्स' < /dev/null > /tmp/js.srwikt.out

It completed in 21s, and of that, 17s was in PEG. Memory usage spiked to about 700M resident but virtual was larger ... since GC is enabled there, not sure how much of it is actually getting freed there.

So, something is up in PEG!

Here is a stack trace from logstash on one of the pages (a different page but basically the same template ( https://sr.wiktionary.org/wiki/%D0%A8%D0%B0%D0%B1%D0%BB%D0%BE%D0%BD:Konjug ) that is used on lots of pages.

#0 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(9005): unknown()
#1 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(6352): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_preproc()
#2 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(4176): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate()
#3 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(3147): Wikimedia\Parsoid\Wt2Html\Grammar->parsetplarg_or_template_guarded()
#4 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(5633): Wikimedia\Parsoid\Wt2Html\Grammar->parsetplarg_or_template()
#5 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(3612): Wikimedia\Parsoid\Wt2Html\Grammar->parseinline_element()
#6 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(3829): Wikimedia\Parsoid\Wt2Html\Grammar->parseinlineline()
#7 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(13357): Wikimedia\Parsoid\Wt2Html\Grammar->parseblock()
#8 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(12397): Wikimedia\Parsoid\Wt2Html\Grammar->parsenested_block()
#9 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(12503): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_param_text()
#10 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(11152): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_param_name()
#11 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(9056): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_param()
#12 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(6352): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_preproc()
#13 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(4176): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate()
#14 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(3147): Wikimedia\Parsoid\Wt2Html\Grammar->parsetplarg_or_template_guarded()
#15 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(5633): Wikimedia\Parsoid\Wt2Html\Grammar->parsetplarg_or_template()
#16 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(3612): Wikimedia\Parsoid\Wt2Html\Grammar->parseinline_element()
#17 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(3829): Wikimedia\Parsoid\Wt2Html\Grammar->parseinlineline()
#18 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(13357): Wikimedia\Parsoid\Wt2Html\Grammar->parseblock()
#19 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(12397): Wikimedia\Parsoid\Wt2Html\Grammar->parsenested_block()
#20 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(12503): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_param_text()
#21 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(11152): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_param_name()
#22 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(9056): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_param()
#23 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(6352): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_preproc()
#24 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(4176): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate()
#25 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(3147): Wikimedia\Parsoid\Wt2Html\Grammar->parsetplarg_or_template_guarded()
#26 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(5633): Wikimedia\Parsoid\Wt2Html\Grammar->parsetplarg_or_template()
#27 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(3612): Wikimedia\Parsoid\Wt2Html\Grammar->parseinline_element()
#28 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(3829): Wikimedia\Parsoid\Wt2Html\Grammar->parseinlineline()
#29 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(13357): Wikimedia\Parsoid\Wt2Html\Grammar->parseblock()
#30 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(12397): Wikimedia\Parsoid\Wt2Html\Grammar->parsenested_block()
#31 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(12503): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_param_text()
#32 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(11152): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_param_name()
#33 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(9056): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_param()
#34 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(6352): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_preproc()
#35 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(4176): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate()
#36 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(3147): Wikimedia\Parsoid\Wt2Html\Grammar->parsetplarg_or_template_guarded()
#37 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(5633): Wikimedia\Parsoid\Wt2Html\Grammar->parsetplarg_or_template()
#38 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(3612): Wikimedia\Parsoid\Wt2Html\Grammar->parseinline_element()
#39 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(3829): Wikimedia\Parsoid\Wt2Html\Grammar->parseinlineline()
#40 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(13357): Wikimedia\Parsoid\Wt2Html\Grammar->parseblock()
#41 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(12397): Wikimedia\Parsoid\Wt2Html\Grammar->parsenested_block()
#42 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(12503): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_param_text()
#43 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(11152): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_param_name()
#44 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(9056): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_param()
#45 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(6352): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_preproc()
#46 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(4176): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate()
#47 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(3147): Wikimedia\Parsoid\Wt2Html\Grammar->parsetplarg_or_template_guarded()
#48 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(5633): Wikimedia\Parsoid\Wt2Html\Grammar->parsetplarg_or_template()
#49 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(3612): Wikimedia\Parsoid\Wt2Html\Grammar->parseinline_element()
#50 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(3829): Wikimedia\Parsoid\Wt2Html\Grammar->parseinlineline()
#51 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(13357): Wikimedia\Parsoid\Wt2Html\Grammar->parseblock()
#52 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(12397): Wikimedia\Parsoid\Wt2Html\Grammar->parsenested_block()
#53 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(12503): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_param_text()
#54 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(11152): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_param_name()
#55 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(9056): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_param()
#56 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(6352): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_preproc()
#57 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(4176): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate()
#58 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(3147): Wikimedia\Parsoid\Wt2Html\Grammar->parsetplarg_or_template_guarded()
#59 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(5633): Wikimedia\Parsoid\Wt2Html\Grammar->parsetplarg_or_template()
#60 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(3612): Wikimedia\Parsoid\Wt2Html\Grammar->parseinline_element()
#61 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(3829): Wikimedia\Parsoid\Wt2Html\Grammar->parseinlineline()
#62 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(13357): Wikimedia\Parsoid\Wt2Html\Grammar->parseblock()
#63 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(12397): Wikimedia\Parsoid\Wt2Html\Grammar->parsenested_block()
#64 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(12503): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_param_text()
#65 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(11152): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_param_name()
#66 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(9056): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_param()
#67 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(6352): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_preproc()
#68 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(4176): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate()
#69 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(3147): Wikimedia\Parsoid\Wt2Html\Grammar->parsetplarg_or_template_guarded()
#70 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(5633): Wikimedia\Parsoid\Wt2Html\Grammar->parsetplarg_or_template()
#71 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(3612): Wikimedia\Parsoid\Wt2Html\Grammar->parseinline_element()
#72 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(3829): Wikimedia\Parsoid\Wt2Html\Grammar->parseinlineline()
#73 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(13357): Wikimedia\Parsoid\Wt2Html\Grammar->parseblock()
#74 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(12397): Wikimedia\Parsoid\Wt2Html\Grammar->parsenested_block()
#75 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(12503): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_param_text()
#76 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(11152): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_param_name()
#77 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(9056): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_param()
#78 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(6352): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_preproc()
#79 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(4176): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate()
#80 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(3147): Wikimedia\Parsoid\Wt2Html\Grammar->parsetplarg_or_template_guarded()
#81 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(5633): Wikimedia\Parsoid\Wt2Html\Grammar->parsetplarg_or_template()
#82 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(3612): Wikimedia\Parsoid\Wt2Html\Grammar->parseinline_element()
#83 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(3829): Wikimedia\Parsoid\Wt2Html\Grammar->parseinlineline()
#84 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(13357): Wikimedia\Parsoid\Wt2Html\Grammar->parseblock()
#85 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(12397): Wikimedia\Parsoid\Wt2Html\Grammar->parsenested_block()
#86 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(12503): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_param_text()
#87 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(11152): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_param_name()
#88 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(9056): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_param()
#89 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(6352): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_preproc()
#90 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(4176): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate()
#91 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(3147): Wikimedia\Parsoid\Wt2Html\Grammar->parsetplarg_or_template_guarded()
#92 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(5633): Wikimedia\Parsoid\Wt2Html\Grammar->parsetplarg_or_template()
#93 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(3612): Wikimedia\Parsoid\Wt2Html\Grammar->parseinline_element()
#94 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(3829): Wikimedia\Parsoid\Wt2Html\Grammar->parseinlineline()
#95 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(13357): Wikimedia\Parsoid\Wt2Html\Grammar->parseblock()
#96 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(12397): Wikimedia\Parsoid\Wt2Html\Grammar->parsenested_block()
#97 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(12503): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_param_text()
#98 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(11152): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_param_name()
#99 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(9056): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_param()
#100 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(6352): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_preproc()
#101 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(4176): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate()
#102 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(3147): Wikimedia\Parsoid\Wt2Html\Grammar->parsetplarg_or_template_guarded()
#103 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(5633): Wikimedia\Parsoid\Wt2Html\Grammar->parsetplarg_or_template()
#104 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(3612): Wikimedia\Parsoid\Wt2Html\Grammar->parseinline_element()
#105 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(3829): Wikimedia\Parsoid\Wt2Html\Grammar->parseinlineline()
#106 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(13357): Wikimedia\Parsoid\Wt2Html\Grammar->parseblock()
#107 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(12397): Wikimedia\Parsoid\Wt2Html\Grammar->parsenested_block()
#108 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(12503): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_param_text()
#109 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(11152): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_param_name()
#110 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(9056): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_param()
#111 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(6352): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_preproc()
#112 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(4176): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate()
#113 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(3147): Wikimedia\Parsoid\Wt2Html\Grammar->parsetplarg_or_template_guarded()
#114 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(5633): Wikimedia\Parsoid\Wt2Html\Grammar->parsetplarg_or_template()
#115 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(3612): Wikimedia\Parsoid\Wt2Html\Grammar->parseinline_element()
#116 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(3829): Wikimedia\Parsoid\Wt2Html\Grammar->parseinlineline()
#117 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(13357): Wikimedia\Parsoid\Wt2Html\Grammar->parseblock()
#118 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(12397): Wikimedia\Parsoid\Wt2Html\Grammar->parsenested_block()
#119 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(12503): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_param_text()
#120 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(11152): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_param_name()
#121 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(9056): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_param()
#122 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(6352): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_preproc()
#123 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(4176): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate()
#124 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(3147): Wikimedia\Parsoid\Wt2Html\Grammar->parsetplarg_or_template_guarded()
#125 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(5633): Wikimedia\Parsoid\Wt2Html\Grammar->parsetplarg_or_template()
#126 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(3612): Wikimedia\Parsoid\Wt2Html\Grammar->parseinline_element()
#127 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(3829): Wikimedia\Parsoid\Wt2Html\Grammar->parseinlineline()
#128 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(13357): Wikimedia\Parsoid\Wt2Html\Grammar->parseblock()
#129 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(12397): Wikimedia\Parsoid\Wt2Html\Grammar->parsenested_block()
#130 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(12503): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_param_text()
#131 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(11152): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_param_name()
#132 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(9056): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_param()
#133 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(6352): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_preproc()
#134 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(4176): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate()
#135 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(3147): Wikimedia\Parsoid\Wt2Html\Grammar->parsetplarg_or_template_guarded()
#136 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(5633): Wikimedia\Parsoid\Wt2Html\Grammar->parsetplarg_or_template()
#137 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(3612): Wikimedia\Parsoid\Wt2Html\Grammar->parseinline_element()
#138 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(3829): Wikimedia\Parsoid\Wt2Html\Grammar->parseinlineline()
#139 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(13357): Wikimedia\Parsoid\Wt2Html\Grammar->parseblock()
#140 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(12397): Wikimedia\Parsoid\Wt2Html\Grammar->parsenested_block()
#141 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(12503): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_param_text()
#142 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(11152): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_param_name()
#143 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(9056): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_param()
#144 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(6352): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_preproc()
#145 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(4176): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate()
#146 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(3147): Wikimedia\Parsoid\Wt2Html\Grammar->parsetplarg_or_template_guarded()
#147 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(5633): Wikimedia\Parsoid\Wt2Html\Grammar->parsetplarg_or_template()
#148 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(3612): Wikimedia\Parsoid\Wt2Html\Grammar->parseinline_element()
#149 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(3829): Wikimedia\Parsoid\Wt2Html\Grammar->parseinlineline()
#150 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(13357): Wikimedia\Parsoid\Wt2Html\Grammar->parseblock()
#151 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(12397): Wikimedia\Parsoid\Wt2Html\Grammar->parsenested_block()
#152 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(12503): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_param_text()
#153 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(11152): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_param_name()
#154 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(9056): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_param()
#155 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(6352): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_preproc()
#156 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(4176): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate()
#157 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(3147): Wikimedia\Parsoid\Wt2Html\Grammar->parsetplarg_or_template_guarded()
#158 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(5633): Wikimedia\Parsoid\Wt2Html\Grammar->parsetplarg_or_template()
#159 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(3612): Wikimedia\Parsoid\Wt2Html\Grammar->parseinline_element()
#160 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(3829): Wikimedia\Parsoid\Wt2Html\Grammar->parseinlineline()
#161 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(13357): Wikimedia\Parsoid\Wt2Html\Grammar->parseblock()
#162 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(12397): Wikimedia\Parsoid\Wt2Html\Grammar->parsenested_block()
#163 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(12503): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_param_text()
#164 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(11152): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_param_name()
#165 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(9056): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_param()
#166 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(6352): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_preproc()
#167 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(4176): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate()
#168 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(3147): Wikimedia\Parsoid\Wt2Html\Grammar->parsetplarg_or_template_guarded()
#169 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(5633): Wikimedia\Parsoid\Wt2Html\Grammar->parsetplarg_or_template()
#170 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(3612): Wikimedia\Parsoid\Wt2Html\Grammar->parseinline_element()
#171 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(3829): Wikimedia\Parsoid\Wt2Html\Grammar->parseinlineline()
#172 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(13357): Wikimedia\Parsoid\Wt2Html\Grammar->parseblock()
#173 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(12397): Wikimedia\Parsoid\Wt2Html\Grammar->parsenested_block()
#174 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(12503): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_param_text()
#175 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(11152): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_param_name()
#176 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(9056): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_param()
#177 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(6352): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_preproc()
#178 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(4176): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate()
#179 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(3147): Wikimedia\Parsoid\Wt2Html\Grammar->parsetplarg_or_template_guarded()
#180 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(5633): Wikimedia\Parsoid\Wt2Html\Grammar->parsetplarg_or_template()
#181 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(3612): Wikimedia\Parsoid\Wt2Html\Grammar->parseinline_element()
#182 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(3829): Wikimedia\Parsoid\Wt2Html\Grammar->parseinlineline()
#183 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(13357): Wikimedia\Parsoid\Wt2Html\Grammar->parseblock()
#184 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(12397): Wikimedia\Parsoid\Wt2Html\Grammar->parsenested_block()
#185 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(12503): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_param_text()
#186 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(11152): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_param_name()
#187 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(9056): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_param()
#188 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(6352): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_preproc()
#189 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(4176): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate()
#190 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(3147): Wikimedia\Parsoid\Wt2Html\Grammar->parsetplarg_or_template_guarded()
#191 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(5633): Wikimedia\Parsoid\Wt2Html\Grammar->parsetplarg_or_template()
#192 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(3612): Wikimedia\Parsoid\Wt2Html\Grammar->parseinline_element()
#193 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(3829): Wikimedia\Parsoid\Wt2Html\Grammar->parseinlineline()
#194 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(13357): Wikimedia\Parsoid\Wt2Html\Grammar->parseblock()
#195 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(12397): Wikimedia\Parsoid\Wt2Html\Grammar->parsenested_block()
#196 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(12503): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_param_text()
#197 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(11152): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_param_name()
#198 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(9056): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_param()
#199 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(6352): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate_preproc()
#200 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(4176): Wikimedia\Parsoid\Wt2Html\Grammar->parsetemplate()
#201 /srv/mediawiki/php-1.36.0-wmf.2/vendor/wikimedia/parsoid/src/Wt2Html/Grammar.php(3147): Wiki

Event Timeline

ssastry triaged this task as High priority.Aug 5 2020, 2:20 AM

Aha!

The page has lots and lots of table cells with this markup: |{{Htitle|mśa (IPA:mʃə)|[[म्श]]| That looks like possible an error. All those {{Htitle snippets get parsed as invalid table cell attributes and get stripped out anyway.

But, getting back to the PEG, in our rules, the rules are probably structured in a way that backtracking cache holds state for it to eventually find a closing }}. This cache is maintained till the end of file, and the fact that there are lots and lots of these cells likely causes the backtracking cache to fill up since there is no }} to be found on the page.

One obvious fix is to edit the page and get rid of all the offending {{Htitle snippets since they are useless anyway. We have the test case for fixing Parsoid in the page history.

ssastry lowered the priority of this task from High to Medium.Aug 5 2020, 2:44 AM

Locally on my laptop with the edit, the page parses in 240MB and 10s now.

Looks like this same PEG pattern is seen on https://zh.wikipedia.org/w/index.php?title=%E7%83%88%E8%BB%8A%E6%88%B0%E9%9A%8A%E7%89%B9%E6%80%A5%E8%80%85&action=edit which has |{{lang|鋼筆暗影怪| code pattern there as well which triggers the same stack trace and causes OOMs. So, if we fix parsing of this broken wikitext pattern, we might reduce our OOM rate!

Hm.. This is a tricky one. In theory both the legacy preprocessor and parsoid have O(N^2) behavior here, and in general for any sequence of {{foo|{{foo|{{foo|{{foo|... that never contains a }}. Each template production tries to find the }}, fails and backtracks into the broken_template production. We were careful not to leave broken_template on the stack here, so the *final* parse tree is O(N) --- but getting to that point is O(N^2) and it appears that our friendly packrat parser is making sure that the memory usage is O(N^2) as well even though the final parse tree is not.

The legacy parser avoids this by doing its processing the *first* time it hits the EOF. It keeps the stack of 'open' constructs, and when it hits EOF without seeing a }}, iterates through the stack calling PPDStackElement_Hash::breakSyntax on each one, which emits the literal text for the template (treating it as a broken construct). Table processing happens in a subsequent pass.

The packrat parser *ought* to be handling this the same way for us: even though we "backtrack" to match broken_template instead of template, in theory the rest of the match should get reused from the packrat cache, so the unwinding should be quick. Either this mechanism isn't working (not entirely surprising, considering the way we've monkeyed with the pegjs cache) or else something about how this is interacting with the table parse is confounding it. It would be interesting to benchmark the {{1x|{{1x|{{1x|{{1x|... example to see if performance scales better with "pure templates" (no tables involved); that would help focus our work if it turns out that the table interaction is important.

We could also consider handling this closer to the way the legacy preprocessor does: instead of the broken_template (etc) productions, use:

template = '{{' tplname tplargs ('}}' / eof)

However, as Grammar.pegphp says,

Then we end up having to reinterpret tplname tplargs* as a tlb if it
turns out we never find the }}, which involves a lot of tedious gluing
tokens back together with fingers crossed we haven't discarded any
significant newlines/whitespace/etc."

That's still effectively a recursive reparse of the contents after the {{.

I think a better solution is to recognize that *the entire stack of open templates* at the time we hit the EOF can be invalidated at once. That is, we can keep that stack of open templates in our parser context and the *first* time we backtrack into the broken_template production we should look at the stack of open syntax elements and mark them as failed; we should then never re-take the non-broken template production for any of these; and if we're not the top-most broken template we should also immediately fail, so that we unwind the stack to the top-most broken template and then reparse from there -- again, ensuring that in this reparse we will *only* take broken_template productions.

This effectively does two parses: once parsing everything as tplname tplargs* in an attempt to make non-broken templates, and then a second time parsing these as tlb* and ensuring that each broken template is parsed as broken.

(But if the regular peg caching mechanism handles this efficiently for {{1x|{{1x|{{1x|... then we shouldn't do any of this, and instead should figure out why the table interaction is breaking things. For example, it could be that the table mechanism ends up recursing into a tlb production, and that clears the backtracking cache. Perhaps all that is necessary is to ensure that table parsing only uses block not tlb...or maybe we shouldn't be clearing the backtracking cache...)

BTW, garbage collection is enabled when you're running parsoid from the command-line. So that's not a relevant difference between Parsoid/PHP and Parsoid/JS.

On my machine:

php bin/parse.php --domain sr.wiktionary.org --pageName='Шаблон:Konjug' --oldid=593154 < /dev/null

completes in 33s w/ 2.5G memory used. Commenting out the part of Grammar.pegphp where we clear the backtracking cache causes it to complete in 34s w/ 2.7G used. So our tlb cleaning is not helping us, but not obviously hurting us either. The issue is that we never actually get back to the tlb production after entering template... at least not until we use broken_template instead, and we are breaking the templates in the wrong order: from the last to the first.

Change 618428 had a related patch set uploaded (by C. Scott Ananian; owner: C. Scott Ananian):
[mediawiki/services/parsoid@master] WIP: improve broken template handling

https://gerrit.wikimedia.org/r/618428

The above patch, which also depends on the wikipeg fix in Ice6613ed9303280183c9f26712cf64a90359c758 (more importantly, that patch's parent), improves parse times on my laptop to xx 28s and 1.6G (down from 33s and 2.5G).

It fixes half the problem: we don't backtrack *up* the template stack down, skipping straight to the topmost broken template and reparsing starting from there. But I think it's still backtracking *down* the template stack, trying each one as a non-broken template before trying it as a template. In theory the PEG cache is suppose to memoize those.

Disabling the bit where we clear the template cache on each TLB brings the runtime down to 25s and 1.7G.

I need to dig a little bit more to verify that the peg cache is doing what I expect it to (ie, one we fail to parse as template from a given character position, it shouldn't try to do so again) and, if not address this (perhaps maintain our own stack of 'known bad templates' based on what's on the stack when we first hit bad_template -- but really, making peg caching work properly would be better).

For reference, if you comment out all the tplarg_or_template_guarded productions *except for* broken_template (which yields the same output in this case, as there are no valid templates on this page AFAICT), parse time is 9s with a memory consumption of 341M.

We're also hitting the maxtemplatedepth restriction, which is causing us to bail to broken_template earlier than we would otherwise. Removing the templatedepth restriction recurses 111 levels deep, and parsing takes 44s with 2.8G used (with the same patch that causes the default maxtemplatedepth=40 to execute in 28s and 1.6G).

It turns out that templatedepth is also busting our PEG cache. It is added as one of the keys to the cache, so every time we resolve one broken_template at top level, the nesting level of all the rest goes down by one, which makes them get re-parsed afresh (since maybe they were only broken last time because the templatedepth was exceeded, and now the templatedepth is lower). (I could probably avoid this by incrementing templatedepth even on broken_template, so that the cache key doesn't change, but that's not how I've hacked it right now.)

By getting rid of the templatedepth restriction (templatedepth=1 instead of templatedepth++) and *not* clearing the peg cache, I can parse this page in 3.6s w/ memory usage of 270M.

Change 618483 had a related patch set uploaded (by C. Scott Ananian; owner: C. Scott Ananian):
[mediawiki/services/parsoid@master] Super-simple fix for OOM

https://gerrit.wikimedia.org/r/618483

^ check out this super simple 'fix'. 9s wall clock, 2.7s user time, 308M used.

ssastry renamed this task from Parsoid is OOMing on srwiktionary pages to pParsoid is OOMing on srwiktionary pages.Aug 5 2020, 9:37 PM
ssastry renamed this task from pParsoid is OOMing on srwiktionary pages to Parsoid is OOMing on srwiktionary pages.
ssastry moved this task from Needs Triage to Current & Upcoming Work on the Parsoid board.
ssastry added a project: Parsing-Active-Work.

Change 618483 merged by jenkins-bot:
[mediawiki/services/parsoid@master] Fix O(N^2) behavior parsing nested broken templates

https://gerrit.wikimedia.org/r/618483

Change 618428 abandoned by C. Scott Ananian:
[mediawiki/services/parsoid@master] WIP: improve broken template handling

Reason:
Abandoned in favor of Iac96c11baeb2ed22272f29955f0a6e0ecf568657

https://gerrit.wikimedia.org/r/618428

ssastry assigned this task to cscott.

Change 619336 had a related patch set uploaded (by C. Scott Ananian; owner: C. Scott Ananian):
[mediawiki/vendor@master] Bump wikimedia/parsoid to v0.13.0-a5

https://gerrit.wikimedia.org/r/619336

Change 619336 merged by jenkins-bot:
[mediawiki/vendor@master] Bump wikimedia/parsoid to v0.13.0-a5

https://gerrit.wikimedia.org/r/619336

After the wmf4 train rollout on group1 wikis, i checked OOM rates on hewiki (which is on group1) and looks like all the OOMs caused by a broken template use in a table on https://he.wikipedia.org/wiki/%D7%AA%D7%91%D7%A0%D7%99%D7%AA%3A%D7%98%D7%91%D7%9C%D7%AA_%D7%9E%D7%92%D7%A4%D7%AA_%D7%94%D7%A7%D7%95%D7%A8%D7%95%D7%A0%D7%94_%D7%91%D7%A2%D7%95%D7%9C%D7%9D are gone.