Preprocessor_Hash: use child arrays instead of linked lists
The singly-linked list data structure of Preprocessor_Hash was causing stack exhaustion due to the need for a recursion depth proportional to the number of children of a given PPNode, in serialize() and on object destruction. So, switch to array-based storage. PPNode_* becomes a temporary proxy around the underlying storage, which avoids circular references and keeps the storage very compact. Preprocessor_DOM uses similar temporary PPNode objects, so the fact that $node->getFirstChild() !== $node->getFirstChild() should not cause any new problems. * Increment cache version * Use JSON serialization of the store array instead of serialize(), since JSON is more compact, even after gzipping. * For efficiency, make $accum a plain array, and use it as an array where possible, instead of using helper functions. Performance and memory usage for typical input are slightly improved: something like 4% faster for the whole parse, and 20% less memory for the tree. Bug: T73486 Change-Id: I0d6c162b790d6dc1ddb0352aba6e4753854f4c56
This commit is contained in:
parent
3e433dd09d
commit
b2f7bb4d76
2 changed files with 463 additions and 391 deletions
|
|
@ -987,7 +987,6 @@ $wgAutoloadLocalClasses = [
|
|||
'PNGMetadataExtractor' => __DIR__ . '/includes/media/PNGMetadataExtractor.php',
|
||||
'PPCustomFrame_DOM' => __DIR__ . '/includes/parser/Preprocessor_DOM.php',
|
||||
'PPCustomFrame_Hash' => __DIR__ . '/includes/parser/Preprocessor_Hash.php',
|
||||
'PPDAccum_Hash' => __DIR__ . '/includes/parser/Preprocessor_Hash.php',
|
||||
'PPDPart' => __DIR__ . '/includes/parser/Preprocessor_DOM.php',
|
||||
'PPDPart_Hash' => __DIR__ . '/includes/parser/Preprocessor_Hash.php',
|
||||
'PPDStack' => __DIR__ . '/includes/parser/Preprocessor_DOM.php',
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue