Use a fixed marker prefix string in the Parser and MWTidy
authorOri Livneh <ori@wikimedia.org>
Tue, 26 May 2015 20:48:33 +0000 (13:48 -0700)
committerOri Livneh <ori@wikimedia.org>
Mon, 1 Jun 2015 02:33:36 +0000 (19:33 -0700)
commit12571bde26d89fd8a86b26e2d8d4012803ddb3d7
tree03e09f6ebefb876405cbbca6ad97cba8ce7f1fb4
parent06cf009d885b5c0133e0293e3c9053c5273eb214
Use a fixed marker prefix string in the Parser and MWTidy

Generating one-time, unique strip markers hurts us in multiple ways:

* The strip marker regexes don't benefit from JIT compilation, so they are
  slower to execute than they could be.
* Although the regexes don't benefit from JIT compilation, they are still
  compiled, because HHVM bets on regexes getting reused. This extra work is
  fairly costly (1-2% of CPU usage on the app servers) and doesn't pay off.
* The size of the PCRE JIT cache is finite, and the caching of one-off regexes
  displaces from the cache regexes which are in fact reused.

Tim's preferred solution (per his review comment on
https://gerrit.wikimedia.org/r/167530/) is to use fixed strip markers.
So:

* Replace usage of $parser->mUniqPrefix with Parser::MARKER_PREFIX, which
  complements the existing Parser::MARKER_SUFFIX.
* Deprecate Parser::mUniqPrefix and its accessor, Parser::uniqPrefix().
* Deprecate Parser::getRandomString(), since it is no longer useful.
* In Preprocessor_*:preprocessToObj() and Parser::fetchTemplateAndTitle,
  replace any occurences of \x7f with '?', to prevent strip marker forgery.
  \x7f is not valid input anyway.
* Deprecate the $prefix parameter for StripState::__construct, since a custom
  prefix may no longer be specified.

Change-Id: I31d4556bbb07acb72c33fda335fa5a230379a03f
RELEASE-NOTES-1.26
includes/parser/MWTidy.php
includes/parser/Parser.php
includes/parser/ParserDiffTest.php
includes/parser/Preprocessor_DOM.php
includes/parser/Preprocessor_Hash.php
includes/parser/StripState.php
languages/LanguageConverter.php