wp-rocket icon indicating copy to clipboard operation
wp-rocket copied to clipboard

Background cpu#6408

Open Khadreal opened this issue 1 year ago • 5 comments

Description

Refactore the regex pattern for css background lazyloading and improve it to be more faster. Fixes #6408

Documentation

User documentation

Explain how this code impacts users.

Technical documentation

Explain how this code works. Diagram & drawings are welcomed.

Type of change

  • [x] Enhancement (non-breaking change which improves an existing functionality).

New dependencies

N/A

Risks

List possible performance & security issues or risks, and explain how they have been mitigated.

Checklists

Feature validation

  • [x] I validated all the Acceptance Criteria. If possible, provide sreenshots or videos.
  • [x] I triggered all changed lines of code at least once without new errors/warnings/notices.
  • [x] I implemented built-in tests to cover the new/changed code.

Documentation

  • [ ] I prepared the user documentation for the feature/enhancement and shared it in the PR or the GitHub issue.
  • [ ] The user documentation covers new/changed entry points (endpoints, WP hooks, configuration files, ...).
  • [ ] I prepared the technical documentation if needed, and shared it in the PR or the GitHub issue.

Code style

  • [x] I wrote self-explanatory code about what it does.
  • [x] I wrote comments to explain why it does it.
  • [x] I named variables and functions explicitely.
  • [x] I protected entry points against unexpected inputs.
  • [x] I did not introduce unecessary complexity.
  • [ ] I listed the introduced external dependencies explicitely on the PR.
  • [ ] I validated the repo-specific guidelines from CONTRIBUTING.md.

Observability

  • [ ] I handled errors when needed.
  • [ ] I wrote user-facing messages that are understandable and provide actionable feedbacks.
  • [ ] I prepared ways to observe the implemented system (logs, data, etc.).

Risks

  • [ ] I explicitely mentioned performance risks in the PR.
  • [ ] I explicitely mentioned security risks in the PR.

Khadreal avatar Feb 15 '24 13:02 Khadreal

Test plan: 1- Run LLBG tests on e2e npm run test:llcssbg => confirms it' passing, if not recheck failed test manually to see if it passes 2- Performance check => running the scenario mentioned here on gamma n times on branch and trunk (compare results) 3- Run related test run https://wpmediaqa.testrail.io/index.php?/runs/view/821&group_by=cases:section_id&group_order=asc 4- Some exploratory test with different themes + page builder

Mai-Saad avatar Feb 20 '24 11:02 Mai-Saad

Why did u update dependencies on this PR?

No dependencies was updated, maybe an oversight

Khadreal avatar Feb 20 '24 14:02 Khadreal

Why did u update dependencies on this PR?

Fixed this

Khadreal avatar Feb 21 '24 06:02 Khadreal

@wordpressfan It seems this PR is pending for your updated review, following your request for changes. Can you have a quick look? Thanks 🙏

MathieuLamiot avatar Feb 26 '24 09:02 MathieuLamiot

About the byte vs. number of characters mentionend by @wordpressfan : Hmm interesting but I think that won't be an issue because all methods we use around the PREG_OFFSET_CAPTURE are working with byte: preg_match_all returns the offset as bytes. Then we do some operations on the original_offset with strlen which also works with bytes. Then we use that value in the next preg_match which expects bytes too.

MathieuLamiot avatar Feb 26 '24 15:02 MathieuLamiot