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

Performance: avoid unnecessary hosting provider detection when possible. #41890

Merged
merged 5 commits into from
Feb 20, 2025

Conversation

jeherve
Copy link
Member

@jeherve jeherve commented Feb 19, 2025

Proposed changes:

This PR brings in a number of changes to improve performance around host detection in our plugins (plugins using My Jetpack, Boost, Social). In general, this starts from a simple premise: in many situations in our codebase, we do not need to know the specific hosting provider on a given site ; we really only want to know that the site is hosted on a specific WordPress.com platform.

All this will also have a nice side-effect ; we will no longer see an error when installing Jetpack on a site built with Studio / Playground. See https://github.com/Automattic/dotcom-forge/issues/10427 for more info.

Note

I added the " I don't care about code coverage for this PR" to this PR since I'm making changes to an existing file that has no tests so far. I would have added some, but it seems there are no tests for the whole Boost app/admin page right now.

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

  • p1739556085639269/1739552940.621129-slack-C06DRMD6VPZ

Does this pull request change what data or activity we track or use?

  • No

Testing instructions:

Note

This needs to be tested on 3 different plugins, installed separately: Jetpack, Boost, and Social.

Jetpack (My Jetpack)

  1. Install the Jetpack plugin
  2. Go to Jetpack > My Jetpack
    • Everything will continue to work just like before.

Boost

  1. Switch to this branch on 3 sites: a self-hosted site (not Jurassic Ninja), a WPCloud site (e.g. Pressable), and a WoA site
  2. Go to Jetpack > Boost
    • On the WoA site, the Page Cache should appear as "active", but can't be toggled. A notice appears under the toggle.
    • On the WPCloud site, the behaviour should be just like above, but with a different notice.
    • On the self-hosted site, you should be able to toggle things on and off.

Social

  1. Switch to this branch on 2 sites: a WoA site, and a self-hosted site.
  2. Go to Jetpack > Social
    • On the WoA site, the support link at the bottom of the page should point to https://jetpack.com/redirect/?source=wpcom-contact-support
    • On the self-hosted site, it points to https://jetpack.com/redirect/?source=jetpack-contact-support

In a lot of situations, we are not interested in knowing the exact hosting provider ; we just want to know if the site is on the WordPress.com platform (and if so, which one).
We do not need to know exactly what host we're with. It's enough to know it's a WordPress.com platform.

See #41076 where this was set up.
We only need to check for specific WordPress.com platforms here (WoA or Atomic), so we can ditch the generic host detection and only look for those 2.

This was added in #39155.
This was added in #34864, but never actually used. We can consequently remove it.
@jeherve jeherve added [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Focus] Performance [Status] In Progress [Pri] Normal labels Feb 19, 2025
@jeherve jeherve self-assigned this Feb 19, 2025
Copy link
Contributor

github-actions bot commented Feb 19, 2025

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WordPress.com Simple site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin, and enable the update/usage-get-nameserver-dns-records branch.

    • For jetpack-mu-wpcom changes, also add define( 'JETPACK_MU_WPCOM_LOAD_VIA_BETA_PLUGIN', true ); to your wp-config.php file.
  • To test on Simple, run the following command on your sandbox:

    bin/jetpack-downloader test jetpack update/usage-get-nameserver-dns-records
    
    bin/jetpack-downloader test jetpack-mu-wpcom-plugin update/usage-get-nameserver-dns-records
    

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions github-actions bot added [Feature] Publicize Now Jetpack Social, auto-sharing [JS Package] Script Data [Package] My Jetpack [Package] Publicize [Package] Status [Plugin] Boost A feature to speed up the site and improve performance. Admin Page React-powered dashboard under the Jetpack menu RNA labels Feb 19, 2025
Copy link
Contributor

github-actions bot commented Feb 19, 2025

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Team Review, ...).
  • ✅ Add a "[Type]" label (Bug, Enhancement, Janitorial, Task).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available.


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Choose a review path based on your changes:
    • A. Team Review: add the "[Status] Needs Team Review" label
      • For most changes, including minor cross-team impacts.
      • Example: Updating a team-specific component or a small change to a shared library.
    • B. Crew Review: add the "[Status] Needs Review" label
      • For significant changes to core functionality.
      • Example: Major updates to a shared library or complex features.
    • C. Both: Start with Team, then request Crew
      • For complex changes or when you need extra confidence.
      • Example: Refactor affecting multiple systems.
  3. Get at least one approval before merging.

Still unsure? Reach out in #jetpack-developers for guidance!


Boost plugin:

  • Next scheduled release: March 3, 2025.

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

Copy link

jp-launch-control bot commented Feb 19, 2025

Code Coverage Summary

Coverage changed in 2 files.

File Coverage Δ% Δ Uncovered
projects/plugins/boost/app/admin/class-config.php 0/36 (0.00%) 0.00% 6 💔
projects/packages/my-jetpack/src/class-initializer.php 52/505 (10.30%) 0.04% -2 💚

Full summary · PHP report · JS report

Coverage check overridden by I don't care about code coverage for this PR Use this label to ignore the check for insufficient code coveage. .

@jeherve jeherve added I don't care about code coverage for this PR Use this label to ignore the check for insufficient code coveage. [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. [Status] Needs Team Review and removed [Status] In Progress labels Feb 19, 2025
@jeherve jeherve requested review from a team February 19, 2025 14:01
@jeherve
Copy link
Member Author

jeherve commented Feb 19, 2025

cc'ing @oskosk since we talked about this on Friday.

Copy link
Member

@manzoorwanijk manzoorwanijk left a comment

Choose a reason for hiding this comment

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

Thank you for this. Works fine.

I wanted to make such a change when that NON_SELF_HOSTED_TYPES was added but I wasn't sure whether unknown is equal to being a Jetpack site.

@jeherve jeherve merged commit e3ea28e into trunk Feb 20, 2025
87 of 88 checks passed
@jeherve jeherve deleted the update/usage-get-nameserver-dns-records branch February 20, 2025 09:35
@github-actions github-actions bot added this to the boost/3.10.0 milestone Feb 20, 2025
@github-actions github-actions bot removed [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. [Status] Needs Team Review labels Feb 20, 2025
pablinos pushed a commit that referenced this pull request Feb 21, 2025
…le. (#41890)

* Status: add parameter to bring more specificity to host detection

In a lot of situations, we are not interested in knowing the exact hosting provider ; we just want to know if the site is on the WordPress.com platform (and if so, which one).

* Script data: provide less specific host info for Jetpack Social

We do not need to know exactly what host we're with. It's enough to know it's a WordPress.com platform.

See #41076 where this was set up.

* Boost: be more specific in hosting provider check.

We only need to check for specific WordPress.com platforms here (WoA or Atomic), so we can ditch the generic host detection and only look for those 2.

This was added in #39155.

* My Jetpack: remove unused parameter.

This was added in #34864, but never actually used. We can consequently remove it.

* Update Phan baseline
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Admin Page React-powered dashboard under the Jetpack menu [Feature] Publicize Now Jetpack Social, auto-sharing [Focus] Performance I don't care about code coverage for this PR Use this label to ignore the check for insufficient code coveage. [JS Package] Script Data [Package] My Jetpack [Package] Publicize [Package] Status [Plugin] Boost A feature to speed up the site and improve performance. [Pri] Normal RNA [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants