-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use persistent cache. #93
Comments
Re. making it a global group I think given that the site ID is part of the SQL query it makes sense. In the rare event anyone would need to query crons for a different site it won't have any issues then. |
The reason I am in two minds about global or single site groups has to do with group invalidation. If the group is global, any time a site on multisite updates a cron job, the queries and jobs for the other sites would be cleared too. If the multisite runs a lot of sites, for example a large company with a presence in multiple countries, then the cache could be lost frequently. For the edge case of cross-site searching, I think it's potentially better as a single site cache. |
Makes sense to me, thanks Peter 👍 |
So, we should keep the cache as non-persistent however we could add a constant that if defined does add it as a persistent global group. This will benefit users not using the runner but just improving cron storage. The database updates in #95 should give a good enough performance boost for those using the runner. |
In order to use the cache in the runner, is it possible to do any of these:
And do this in a backward compatible way to avoid ruining everything if the plugin is updated without the runner or vice versa? |
We'd essentially have to load all of WordPress in to be able to use the object cache, which is highly likely to cause severe memory leaks and undefined behaviour, since WordPress isn't designed for long-running processes. What we could potentially do is move these operations from the runner into the |
Could Cavalcade the plugin use the runner's |
Altis Cloud is loaded differently; it's loaded as part of Altis during the very early stages of the bootstrap setup, and crucially, as part of the We could provide a special mode for Cavalcade that says "yes, it's loaded in early and the cache should be enabled", but that seems like a very messy solution that doesn't gain us much. Curious to know if you're seeing actual perf problems from the lack of cache. I'm yet to see it take any significant amount of time, even on sites with a lot of jobs. |
We're not seeing any at the moment, but I'm concerned about the affect of the increased number of DB calls by using the new filters. Work has a few hundred journalists in the admin all day so we don't get the benefit of full page caching. How about introducing a filter in wp-config.php: use HM\Cavalcade\Runner\Runner;
require_once __DIR__ . '/wordpress/wp-includes/plugin.php';
Runner::instance()->hooks->register( 'Runner.check_workers.job_completed', function() {
wp_cache_set( 'last_changed', microtime(), 'cavalcade-jobs' );
} );
add_filter( 'hm.cavalcade.use-persistent-cache', function() {
return false;
} ); cavalcade/inc/namespace.php: /**
* Register the cache groups
*/
function register_cache_groups() {
wp_cache_add_global_groups( [ 'cavalcade' ] );
/**
* Docblock with clear warning about how to use this.
*/
$persistent_cache = apply_filters( 'hm.cavalcade.use-persistent-cache', true );
if ( ! $persistent_cache ) {
return;
}
wp_cache_add_non_persistent_groups( [ 'cavalcade-jobs' ] );
} |
WordPress.org was having a particularly high number of database hits recently. While rubber ducking a fix/work around with Dion I was wondering if a persistent cache could be cleared on the At this stage, this is a pretty random brain expulsion: do y'all reckon it's worth exploring? |
In the case of WordPress.org, it was a surge of uncached hits that caused issues which resulted in loading of WordPress and causing many cronjobs to be checked for existence on each request. I've recently added some super simple caching to In the case of WordPress.org, caching the For reference, here's a bit of code I've deployed on WordPress.org with a super short 10s cache, it's not designed to be super efficient or cover all bases, just to limit the number of repetitive queries for jobs that have been running fine for in some cases literally years.
It seemed to do the trick and hasn't caused any visible effects yet (such as duplicate scheduled tasks etc) |
Follow up to discussion in PR #91
Cavalcade uses a non-persistent cache for the
cavalcade-jobs
group. As the runner triggers WP CLI tasks within the plugin, invalidating on UPDATE, INSERT and DELETE should be a relatively simple task.Proposal:
cavalcade-jobs
from the non-persistent groupscavalcade-jobs
should be a global or per siteThe text was updated successfully, but these errors were encountered: