Improve timeout calculations with more accurate start time and by including all tasks #1035
Labels
priority: normal
The issue/PR is normal priority—not many people are affected or there’s a workaround, etc.
type: enhancement
The issue is a request for an enhancement.
I'd like to suggest a few small improvements and hope to gather some feedback on them:
$this->created_time = microtime( true );
in QueueRunner should be changed to:Since the action scheduler might only be loaded after a significant amount of time has passed already (especially in wp-admin with the async request, there are loads of incredibly slow sites) thus distorting the calculations
time_likely_to_be_exceeded
only takes into account the$processed_actions
- however this can be off signifcantly if the time between the time the request started (even worse now with the change of 1) and the time "run" was called - either bc some unrelated stuff beforehand was slow (see 1) OR there were lots of clean up tasks that took a while.I suggest to create an additional property which holds microtime( true ) immediately before the do/while loop in
run
starts and use only that to calculate the average action time.$estimated_time = $execution_time + ( $time_per_action * 3 );
should be changed to
This will massively reduce DB load and speed up execution because:
Perhaps even
*1.5
it to be on the save side (should be apply filterable too)EDIT: for 3) where
batch_limits_exceeded
is called indo_batch
- this needs to be handled separately too, since there it should not use the batch size or hardcoded 3, but it should use only 1, bc we only need to break when the next iteration of the loop will put us over the limit.The text was updated successfully, but these errors were encountered: