[Performance] Use the WordPress caching layer for the option lock component.#1342
Conversation
barryhughes
left a comment
There was a problem hiding this comment.
This looks like a nice approach to me, and I think will add a small improvement even when there is no persistent caching layer (because ActionScheduler_QueueRunner::maybe_dispatch_async_request() effectively reads the lock twice in the same request).
I realize it's a draft, so this is likely planned, but definitely worth additional tests.
6b4656f to
cb1bfa4
Compare
barryhughes
left a comment
There was a problem hiding this comment.
Nice!
I left a non-blocking comment but this looks good and tests well. I supported the testing instructions with a further snippet to create a small stream of past-due actions:
add_action( 'action_scheduler_init', function () {
rand( 0, 1 ) ? as_enqueue_async_action( 'test-pr-1342' ) : 0;
} );These continued to be vacuumed up at the expected cadence (albeit there wasn't much contention in my local env, I didn't see cases where lock acquisition was notably delayed).

Introduces the following changes to the
\ActionScheduler_OptionLockcomponent:Manual testing: