#56636 closed defect (bug) (fixed)
Bug/performance: duplicate use of realpath()
| Reported by: | aristath | Owned by: | SergeyBiryukov |
|---|---|---|---|
| Priority: | normal | Milestone: | 6.1 |
| Component: | General | Version: | 6.1 |
| Severity: | normal | Keywords: | has-patch add-to-field-guide |
| Cc: | Focuses: | performance |
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.
4 years ago
#1
- Keywords has-patch added
#2
@
4 years ago
- Summary Performance: duplicate use of realpath() → Bug/performance: duplicate use of realpath()
SergeyBiryukov commented on PR #3317:
4 years ago
#5
Thanks for the PR! Merged in r54290.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
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