Skip to content

PEG.js based parser introduced a performance regression #1646

@ocean90

Description

@ocean90

After updating the plugin on a site I noticed a performance decrease by 2-3 seconds.

$ wp profile stage --fields=stage,time,cache_ratio
+------------+---------+-------------+
| stage      | time    | cache_ratio |
+------------+---------+-------------+
| bootstrap  | 1.0175s | 88.3%       |
| main_query | 0.025s  | 90.74%      |
| template   | 4.3431s | 93.54%      |
+------------+---------+-------------+
| total (3)  | 5.3856s | 90.86%      |
+------------+---------+-------------+

vs.

$ wp profile stage --fields=stage,time,cache_ratio --skip-plugins=gutenberg
+------------+---------+-------------+
| stage      | time    | cache_ratio |
+------------+---------+-------------+
| bootstrap  | 1.0935s | 88.09%      |
| main_query | 0.0206s | 90.74%      |
| template   | 0.3426s | 93.54%      |
+------------+---------+-------------+
| total (3)  | 1.4567s | 90.79%      |
+------------+---------+-------------+

Checking further

wp profile stage template --fields=hook,time,cache_ratio
+--------------------------+---------+-------------+
| hook                     | time    | cache_ratio |
+--------------------------+---------+-------------+
| template_redirect:before | 0.001s  |             |
| template_redirect        | 0.0239s | 98.46%      |
| template_include:before  | 0.0008s | 100%        |
| template_include         | 0s      |             |
| wp_head:before           | 0.0028s | 100%        |
| wp_head                  | 0.0904s | 98.31%      |
| loop_start:before        | 0.0287s | 93.58%      |
| loop_start               | 0s      |             |
| loop_end:before          | 3.1046s | 91.02%      |
| loop_end                 | 0s      |             |
| wp_footer:before         | 0.0607s | 92.7%       |
| wp_footer                | 0.0017s | 100%        |
| wp_footer:after          | 0.0002s |             |
+--------------------------+---------+-------------+
| total (13)               | 3.315s  | 96.76%      |
+--------------------------+---------+-------------+

So I removed the filter on the_content and the load was back to normal. I also reverted the do_blocks() function to the previous version and the load was still normal. But once the PEG version is in use the page load increases by ~3 seconds.

Will investigate further to get the exact cause for this.

Metadata

Metadata

Assignees

Labels

[Feature] ParsingRelated to efforts to improving the parsing of a string of data and converting it into a different f[Priority] HighUsed to indicate top priority items that need quick attention[Type] BugAn existing feature does not function as intended

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions