#56636 closed defect (bug) (fixed)
Bug/performance: duplicate use of realpath()
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 6.1 | Priority: | normal |
| Severity: | normal | Version: | 6.1 |
| Component: | General | Keywords: | has-patch add-to-field-guide |
| Focuses: | performance | Cc: |
Description (last modified by )
While running Xdebug profiling with webgring in WP-Core, I noticed that realpath() is getting called too many times and costs a lot of time.
After some examination, I found that the register_block_style_handle() function calls realpath to set a $style_path_norm variable, and then a few lines below that, sets a $style_file variable with the exact same value, recalculating things and re-running realpath.
This is a simple bugfix and saves some performance. More details and screenshots in the PR
Change History (7)
This ticket was mentioned in PR #3317 on WordPress/wordpress-develop by aristath.
3 years ago
#1
- Keywords has-patch added
#2
@
3 years ago
- Summary changed from Performance: duplicate use of realpath() to Bug/performance: duplicate use of realpath()
#4
@
3 years ago
- Owner set to SergeyBiryukov
- Resolution set to fixed
- Status changed from new to closed
In 54290:
SergeyBiryukov commented on PR #3317:
3 years ago
#5
Thanks for the PR! Merged in r54290.
This ticket was mentioned in Slack in #core by sergey. View the logs.
3 years ago
Note: See
TracTickets for help on using
tickets.
This patch removes duplicate calculations for a variable, reducing by half the number of times we call
realpath().Tests ran using Xdebug & webgind, attaching screenshots of the reports:
Before the patch:
After the patch:
Invocation count goes down from 639 to 461. Total self-cost goes down from 146ms to 89ms (values shown are in milliseconds).
Trac ticket: https://core.trac.wordpress.org/ticket/56636