#61276 closed enhancement (fixed)
Add "Audit Autoloaded Options" Site Health Check
Reported by: | mukesh27 | Owned by: | joemcgill |
---|---|---|---|
Milestone: | 6.6 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Site Health | Keywords: | has-patch has-unit-tests has-testing-info has-screenshots 2nd-opinion commit |
Focuses: | performance | Cc: |
Description (last modified by )
The sites with many unnecessary autoloaded options face significant performance problems ( #54221, #42441 ). It's challenging for site owners to monitor and resolve these issues on their own, which can lead to suboptimal site performance and slower load times.
To address this, I propose adding a new "Audit Autoloaded Options" Site Health check to core. This would add a new test in the WordPress Site Health checks to monitor and report on the autoloaded options. This functionality helps in assessing and maintaining optimal site performance by providing insights into the number and size of autoloaded options.
An implementation of this Site Health check is already included in the Performance Lab plugin.
Key Features:
- Integration with Site Health:
- Adds a test under the Site Health section to monitor autoloaded options.
- Displays the number and size of autoloaded options.
- Status Indication:
- Shows a 'good' status if the autoloaded options are within acceptable limits.
- Shows a 'critical' status if the autoloaded options exceed the predefined threshold (default: 800,000 bytes), indicating a potential performance issue.
- Customizable Threshold:
- Introduces a filter (
wp_autoloaded_options_limit_size_in_bytes
) to adjust the threshold size for triggering warnings.
- Introduces a filter (
Attachments (2)
Change History (44)
#2
@
7 months ago
- Milestone changed from Awaiting Review to 6.6
- Owner set to mukesh27
- Status changed from new to assigned
This ticket was mentioned in PR #6622 on WordPress/wordpress-develop by @mukesh27.
7 months ago
#3
- Keywords has-patch has-unit-tests added; needs-patch needs-unit-tests removed
#4
@
7 months ago
- Keywords changes-requested needs-testing added
Thanks, @mukesh27. This is a nice addition that will could pair well with r57920 which is set to ship in this release.
I'd like to get more eyes before committing and have left a few suggestions on the PR.
@mukesh27 commented on PR #6622:
6 months ago
#5
It seems like Tests with GB src and build is failing :x:
Cannot access this declaration file. You may need to run tsc again: /home/runner/work/wordpress-develop/wordpress-develop/src/wp-content/plugins/gutenberg/packages/core-data/build-types/index.d.ts
#6
@
6 months ago
- Keywords changes-requested removed
@joemcgill, thanks for the feedback. I have addressed those issues. The PR is now ready for review.
This ticket was mentioned in Slack in #core-test by mukeshpanchal27. View the logs.
6 months ago
#8
follow-up:
↓ 9
@
6 months ago
@mukesh27
Could we show the things with bullet pointers which are the main high lighters?
E.g. Instead of Your site has 118 autoloaded options (size: 25 KB) in the options table, which is acceptable.
shouldn't we show something like this?
- Your site has 118 autoloaded options
- The size is 25KB
- Is acceptable? Yes/No (What ever the status)
Also, it does not show Status Indication
as you have explained in the issue description. Please confirm if I missed any thing or should it be checked elsewhere?
Please check the attched screenshot.
#9
in reply to:
↑ 8
@
6 months ago
Replying to krupajnanda:
Could we show the things with bullet pointers which are the main high lighters?
With the site health check, we are going to provide some information to the site author. Including a paragraph makes sense for this purpose. I don't oppose for the bullet point.
Also, it does not show
Status Indication
as you have explained in the issue description. Please confirm if I missed any thing or should it be checked elsewhere?
Critical status: If the autoload options size exceeds the limit (in our case, 800000), the test fails and displays a critical error. Refer to the first image in this https://github.com/WordPress/wordpress-develop/pull/6622#pullrequestreview-2078097626. To test this scenario in a fresh WordPress installation, use the filter shown in the PR comment.
Good status: If the autoload options size is below the limit (in our case, 800000), the test passes. Refer to the last image in this https://github.com/WordPress/wordpress-develop/pull/6622#pullrequestreview-2078097626.
#10
@
6 months ago
Hi,
Test Report
Patch - https://github.com/WordPress/wordpress-develop/pull/6622
Environment:
OS: Mac
WordPress: 6.6-alpha
PHP: v8.1
Browser: Mac
Expected Result: The test under the Site Health section for the autoloaded option is visible properly. However, I tried adding the wp_autoloaded_options_limit_size_in_bytes filter inside MU plugin but it didn't show the critical status to me.
Screenshot:
https://prnt.sc/nDfdjJ7SI00j
Thanks
#11
@
6 months ago
Test Report ✅
This new enhancement works as expected in my test.
Patch tested: https://github.com/WordPress/wordpress-develop/pull/6622
Environment
- WordPress: 6.6-alpha-20240527.194552
- PHP: 8.3.0
- Server: nginx/1.16.0
- Database: mysqli (Server: 5.7.28 / Client: mysqlnd 8.3.0)
- Browser: Chrome 124.0.0.0
- OS: macOS
- Theme: Twenty Sixteen 3.2
- MU Plugins:
- Autoloaded Options Limit Disabler 1.0
Actual Results
- ✅ Enhancement works fine with purposeed PR.
Additional Notes
When autoloaded options exceed the predefined threshold:
When autoloaded options are within acceptable limits.
#12
@
6 months ago
@mukesh27 Please check the report mentioned below.
Test Report
Patch tested: https://github.com/WordPress/wordpress-develop/pull/6622
Environment
- WordPress: 6.6-alpha-57778-src
- PHP: 8.2.15
- Server: nginx/1.25.3
- Database: mysqli (Server: 8.0.36 / Client: mysqlnd 8.2.15)
- Browser: Chrome 124.0.0.0
- OS: macOS
- Theme: Twenty Twenty-Four 1.1
- MU Plugins:
- autoload-checker.php
- Plugins:
- Test Reports 1.1.0
Expected Result :
It should show critical if I add below filter in my mu plugin.
add_filter( 'wp_autoloaded_options_limit_size_in_bytes', '__return_zero' );
Actual Results
I am not able to replicate the "Critical Issue" for autoloader. ❎
Additional Notes
- I tried couple of different values with this filter but unable to replicate the expected result. Every time it shows only Autoloaded options are acceptable.
add_filter( 'wp_autoloaded_options_limit_size_in_bytes', '__return_zero' );
This ticket was mentioned in Slack in #core-test by krupajnanda. View the logs.
6 months ago
#15
@
6 months ago
Thanks @pooja1210 and @krupajnanda for testing. In recent review feedback i have updated the filter name so update filter is:
add_filter( 'site_status_autoloaded_options_size_limit', '__return_zero' );
#16
@
6 months ago
- Keywords has-screenshots added
@mukesh27 Thank you for sharing the updated filter and after trying with that I am able to replicate the expected result. Please check the report attached below.
Test Report
Description
This report validates whether the indicated patch works as expected. ✅
Patch tested: https://github.com/WordPress/wordpress-develop/pull/6622
Environment
- WordPress: 6.6-alpha-57778-src
- PHP: 8.2.15
- Server: nginx/1.25.3
- Database: mysqli (Server: 8.0.36 / Client: mysqlnd 8.2.15)
- Browser: Chrome 124.0.0.0
- OS: macOS
- Theme: Twenty Twenty-Four 1.1
- MU Plugins:
- Safe Autoloaded Options Limit Test (MU Plugin) 1.0
- Plugins:
- Test Reports 1.1.0
Actual Results
- ✅ Issue resolved with patch.
Supplemental Artifacts
Add as Attachment
#17
@
6 months ago
- Keywords has-screenshots removed
Hello @krupajnanda @pooja1210, I was able to generate a Critical Issue by updating the threshold in database.
When I change the value with below query, critical issue was appearing on Site Health section.
INSERT INTO `wp_options` (`option_name`, `option_value`, `autoload`) VALUES ('test_large_option', REPEAT('a', 800000), 'yes');
#19
@
6 months ago
- Keywords needs-testing removed
Thanks for testing folks.
All ✅ per the tests reports.
#20
@
6 months ago
- Keywords needs-testing added
@ankit-k-gupta Thank you for sharing the details. I am able to replicate the expected behaviour now with the help of the newly shared filter. 🙌
#22
@
6 months ago
Hi @mukesh27,
I have verified the recent changes and those are working fine. Here's the test report for the same.
Test Report
Patch tested - https://github.com/WordPress/wordpress-develop/pull/6622/commits/026182b6e4e7da237fb90d15d4d104a3c0a7f14f
Environment:
OS: Mac
WordPress: 6.6-alpha
PHP: v8.1
Browser: Chrome v125
MU Plugins: Increase autoload options limit
Results: The changes are working fine. Test under the Site Health section for the autoloaded option is visible properly and if the autoload limit is exceeded the test falls and a critical error is visible.
Screenshot
Critical Status: https://prnt.sc/pvVVGBzy_sbY
Good status: https://prnt.sc/nDfdjJ7SI00j
Thanks
#23
@
6 months ago
- Keywords 2nd-opinion added
Is this health check actionable by an end user?
Let's say I run the health check and everything is ok except for the message saying "Autoloaded options could affect performance". The message essentially suggests deleting some options from the options table. The handbook page that it links to says "For step-by-step instructions on viewing and changing autoloaded options, check with your hosting provider" which is questionable.
If I see this message on my site, what am I actually going to do with it?
This ticket was mentioned in Slack in #core-performance by joemcgill. View the logs.
6 months ago
#25
@
6 months ago
I have doubts about the phrase: "You can reduce the number of autoloaded options by cleaning up your site's options table". I had an experience (with another CMS I don't like at all) when I've told the manager not to store images into the public_html folder, and she deleted everything from it except subfolders to make things pretty. 🙈 So, taking this phrase as it is, a person can go into the database and truncate the options table. Btw, not loading some options can damage performance too because they will be loaded one by one when needed. And, am I right in thinking that not autoloaded transients are taking two trips into the database? 🤔
I believe that the correct way is to notify the user about the problem, with note that this issue should be handled by the developer.
This information will be useful for developers to pay attention to, it is very convenient to have it usually as a site maintainer you are not thinking about such things (expecting that theme or plugins developers are known what they are doing). Possibly it could be added to the Directories and Sizes panel of the Info tab. This also can bring attention of themes and plugins developers to what they are autoloading. "To load or not to load" can be a tough decision 🙂
#26
@
6 months ago
Thanks, @johnbillion and @oglekler, for your thoughts.
Is the phase a blocker for this health check? I would like to update it as below. Let me know what you think.
Before:
Autoloaded options are configuration settings for plugins and themes that are automatically loaded with every page load in WordPress. Having too many autoloaded options can slow down your site. Your site has xyz autoloaded options (size: xx KB) in the options table, which could cause your site to be slow. You can reduce the number of autoloaded options by cleaning up your site's options table.
After:
Autoloaded options are configuration settings for plugins and themes that are automatically loaded with every page load in WordPress. Having too many autoloaded options can slow down your site. Your site has xyz autoloaded options (size: xx KB) in the options table, which could cause your site to be slow. It is advisable to have a developer review and clean up these options to prevent potential slowdowns.
#27
@
6 months ago
@mukesh27 I think, proposed phrase with an advice to get a developer on this task is good enought. Let's found out what John thinks. This is quite important information to have in the Health Check 🚀
#28
@
6 months ago
While I appreciate the intent to help users not harm there site, I don't particularly like the insinuation that people aren't capable of reviewing documentation and deciding for themselves whether they need to contact someone to assist them with a site maintenance task.
I'd suggest saying something like:
Autoloaded options are configuration settings for plugins and themes that are automatically loaded with every page load in WordPress. Having too many autoloaded options can slow down your site. Your site has xyz autoloaded options (size: xx KB) in the options table, which could cause your site to be slow.
You can review the options being autoloaded in your database and remove any options that are no longer needed by your site
.
We also already include a link to https://developer.wordpress.org/advanced-administration/performance/optimization/#autoloaded-options with some follow-up instructions, which we can probably improve further.
@mukesh27 commented on PR #6622:
6 months ago
#29
Thanks, @costdev, for the feedback.
@joemcgill, I have updated the copy content.
#30
@
6 months ago
- Keywords commit added
- Owner changed from mukesh27 to joemcgill
I'm marking this for commit consideration and will handle this prior to the beta 1 code freeze tomorrow unless someone beats me to it or there is new info that would suggest not including this check in 6.6
@joemcgill commented on PR #6622:
6 months ago
#32
#33
@
6 months ago
- Resolution fixed deleted
- Status changed from closed to reopened
@joemcgill I think the commit is missing the hardening fix from https://github.com/WordPress/performance/pull/1238
This ticket was mentioned in Slack in #core-performance by clarkeemily. View the logs.
6 months ago
#35
@
6 months ago
- Type changed from enhancement to defect (bug)
Thanks @westonruter. Let's address that fix during beta. I'm going to temporarily change this to a bug until the beta release is done to not block the release process.
This ticket was mentioned in PR #6725 on WordPress/wordpress-develop by @mukesh27.
6 months ago
#36
Trac ticket: https://core.trac.wordpress.org/ticket/61276
@mukesh27 commented on PR #6725:
6 months ago
#37
@westonruter I have open PR that account that issue. cc. @joemcgill
#39
@
6 months ago
- Type changed from defect (bug) to enhancement
Setting this back to an enhancement ticket now that 6.6 Beta 1 has been shipped to reflect to correct type.
Trac ticket: https://core.trac.wordpress.org/ticket/61276