Skip to content
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

Preload adaptative batch #6427

Open
wants to merge 44 commits into
base: develop
Choose a base branch
from

Conversation

MathieuLamiot
Copy link
Contributor

Description

When preparing preload batches, the batch size will be adapted based on the average duration of a request to avoid flooding servers with requests if they take too long.
To get the estimate of the request duration, we do a blocking request from time to time when triggering the preload, and measure the timing.

Fixes #6396

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality).

Is the solution different from the one proposed during the grooming?

Yes, on top of the original idea, we added an average mechanism that keeps track of the average request time through transients.

Checklists

Generic development checklist

  • My code follows the style guidelines of this project, with adapted comments and without new warnings.
  • I have added unit and integration tests that prove my fix is effective or that my feature works.
  • The CI passes locally with my changes (including unit tests, integration tests, linter).
  • Any dependent changes have been merged and published in downstream modules.
  • If applicable, I have made corresponding changes to the documentation. Provide a link to the documentation.

Test summary

  • I triggered all changed lines of code at least once without new errors/warnings/notices.
  • I validated all Acceptance Criteria of the related issues. (If applicable, provide proof).
  • I validated all test plan the QA Review asked me to.

Tested locally and on the gamma website by checking transients and scheduled actions.

@MathieuLamiot MathieuLamiot linked an issue Feb 1, 2024 that may be closed by this pull request
@MathieuLamiot MathieuLamiot requested a review from a team February 27, 2024 11:46
inc/Engine/Preload/Controller/PreloadUrl.php Outdated Show resolved Hide resolved
inc/Engine/Preload/Controller/PreloadUrl.php Outdated Show resolved Hide resolved
inc/Engine/Preload/Controller/PreloadUrl.php Outdated Show resolved Hide resolved
@Khadreal Khadreal self-assigned this Feb 29, 2024
@MathieuLamiot
Copy link
Contributor Author

MathieuLamiot commented Mar 11, 2024

@Khadreal Hey, I just pushed a small change to enforce the max batch size after the min batch size. This is for the case there are already 45 actions in the AS queue. In this case, no matter what, we don't want to add more to the AS queue. So the max has to be enforced after.
Checking the tests now

Copy link

codacy-production bot commented Jun 12, 2024

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
Report missing for e67e7691 100.00% (target: 50.00%)
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (e67e769) Report Missing Report Missing Report Missing
Head commit (d00b8ee) 37291 14485 38.84%

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#6427) 27 27 100.00%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences


🚀 Don’t miss a bit, follow what’s new on Codacy.

Codacy stopped sending the deprecated coverage status on June 5th, 2024. Learn more

Footnotes

  1. Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.

@Tabrisrp Tabrisrp requested review from jeawhanlee, Khadreal and a team and removed request for Khadreal and jeawhanlee June 13, 2024 20:48
@Tabrisrp Tabrisrp added type: enhancement Improvements that slightly enhance existing functionality and are fast to implement module: preload labels Jun 13, 2024
/**
* Filter the delay between each preload request.
*
* @param float $delay_between the defined delay.
* @returns float
*/
$delay_between = apply_filters( 'rocket_preload_delay_between_requests', 500000 );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know it's not been added by this PR, but shouldn't we add a safeguard here ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module: preload type: enhancement Improvements that slightly enhance existing functionality and are fast to implement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[R&D] Adaptative batch size on Preload
5 participants