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

Restricting fetchModuleList calls to Atomic sites only #91170

Merged
merged 5 commits into from
May 29, 2024

Conversation

paulopmt1
Copy link
Contributor

@paulopmt1 paulopmt1 commented May 27, 2024

Related to #90758

Proposed Changes

  • We're restricting whether to make the fetchmoduleList call for Atomic sites only

Here's more context to it.

Why are these changes being made?

  • This isn't a fix for the issue, but instead, a performance improvement since we're avoiding a couple of unnecessary calls with it (fetchModuleList + JetpackHealthCheck).

Testing Instructions

  • Be on this branch and select a simple site
  • Go to Home on that simple site and clear your Network requests
  • Go to Pages -> All pages
  • Ensure you won't see a /rest/v1.1/jetpack-blogs API call

Pre-merge Checklist

  • Has the general commit checklist been followed? (PCYsg-hS-p2)
  • Have you written new tests for your changes?
  • Have you tested the feature in Simple (P9HQHe-k8-p2), Atomic (P9HQHe-jW-p2), and self-hosted Jetpack sites (PCYsg-g6b-p2)?
  • Have you checked for TypeScript, React or other console errors?
  • Have you used memoizing on expensive computations? More info in Memoizing with create-selector and Using memoizing selectors and Our Approach to Data
  • Have we added the "[Status] String Freeze" label as soon as any new strings were ready for translation (p4TIVU-5Jq-p2)?
  • For changes affecting Jetpack: Have we added the "[Status] Needs Privacy Updates" label if this pull request changes what data or activity we track or use (p4TIVU-aUh-p2)?

@paulopmt1 paulopmt1 changed the title Making fetchModuleList calls only for Atomic sites Restricting fetchModuleList calls to Atomic sites only May 27, 2024
@paulopmt1 paulopmt1 self-assigned this May 27, 2024
@paulopmt1 paulopmt1 requested a review from tyxla May 27, 2024 18:41
@matticbot matticbot added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label May 27, 2024
@paulopmt1 paulopmt1 requested a review from a team May 27, 2024 18:42
@matticbot
Copy link
Contributor

matticbot commented May 27, 2024

Here is how your PR affects size of JS and CSS bundles shipped to the user's browser:

Sections (~451 bytes added 📈 [gzipped])

name                  parsed_size           gzip_size
stats                      +145 B  (+0.0%)      +38 B  (+0.0%)
settings-writing           +145 B  (+0.0%)      +59 B  (+0.0%)
settings-security          +145 B  (+0.0%)      +45 B  (+0.0%)
settings-performance       +145 B  (+0.0%)      +45 B  (+0.0%)
settings-newsletter        +145 B  (+0.0%)      +50 B  (+0.0%)
settings-discussion        +145 B  (+0.0%)      +48 B  (+0.0%)
posts-custom               +145 B  (+0.0%)      +31 B  (+0.0%)
posts                      +145 B  (+0.0%)      +31 B  (+0.0%)
people                     +145 B  (+0.0%)      +36 B  (+0.0%)
pages                      +145 B  (+0.0%)      +31 B  (+0.0%)
media                      +145 B  (+0.0%)      +43 B  (+0.0%)
marketing                  +145 B  (+0.0%)      +43 B  (+0.0%)
jetpack-social             +145 B  (+0.0%)      +43 B  (+0.0%)
jetpack-search             +145 B  (+0.0%)      +37 B  (+0.0%)
hosting                    +145 B  (+0.0%)      +19 B  (+0.0%)

Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to.

Async-loaded Components (~43 bytes added 📈 [gzipped])

name                                               parsed_size           gzip_size
async-load-calypso-post-editor-media-modal              +145 B  (+0.0%)      +43 B  (+0.0%)
async-load-calypso-post-editor-editor-media-modal       +145 B  (+0.0%)      +43 B  (+0.0%)

React components that are loaded lazily, when a certain part of UI is displayed for the first time.

Legend

What is parsed and gzip size?

Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory.
Gzip Size: Compressed size of the JS and CSS files. This much data needs to be downloaded over network.

Generated by performance advisor bot at iscalypsofastyet.com.

Copy link
Contributor

@vykes-mac vykes-mac left a comment

Choose a reason for hiding this comment

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

Change seem reasonable and the extra call is not made.

Copy link
Member

@tyxla tyxla left a comment

Choose a reason for hiding this comment

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

I believe we need to consider non-Atomic Jetpack sites in the equation as well.


const request = ( siteId ) => ( dispatch, getState ) => {
if ( siteId && ! isFetchingJetpackModules( getState(), siteId ) ) {
const isAtomic = isSiteWpcomAtomic( getState(), siteId );
Copy link
Member

Choose a reason for hiding this comment

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

What about non-atomic Jetpack sites? From what I recall, Jetpack sites (which aren't necessarily Atomic sites) also used the module data - extensively in site settings (but not only there).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch @tyxla! Adding support to Jetpack non-Atomic sites here: 2e34bb3

if ( siteId && ! isFetchingJetpackModules( getState(), siteId ) ) {
const isAtomic = isSiteWpcomAtomic( getState(), siteId );

if ( siteId && ! isFetchingJetpackModules( getState(), siteId ) && isAtomic ) {
Copy link
Member

Choose a reason for hiding this comment

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

It can be convenient to add this site type limitation here, but it also means we have to test every combination of the following:

  • Area/component where the QueryJetpackModules query component is used
  • Site type that supports (or doesn't support) Jetpack modules - Atomic sites, non-Atomic Jetpack sites, simple sites, etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Area/component where the QueryJetpackModules query component is used

I tested it on its usages, and they are working as expected:

  • Pages -> All pages
  • Settings -> Newsletter
  • Tools -> Marketing

Jetpack modules - Atomic sites, non-Atomic Jetpack sites, simple sites, etc.

  • Atomic sites and non-Atomic Jetpack sites are working as expected after this change.
  • Simple site is not calling it as expected.

@matticbot
Copy link
Contributor

This PR modifies the release build for the following Calypso Apps:

For info about this notification, see here: PCYsg-OT6-p2

  • wpcom-block-editor

To test WordPress.com changes, run install-plugin.sh $pluginSlug fix/remove-unnecessary-jetpack-call on your sandbox.

@paulopmt1 paulopmt1 requested a review from tyxla May 28, 2024 17:50
Copy link
Member

@tyxla tyxla left a comment

Choose a reason for hiding this comment

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

Left a couple more nits on the unit tests, but nothing critical - this looks good to go 🚀

isWpcomAtomic = true;
isJetpack = false;
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't seem like a valid scenario. AFAIK there can't be a working Atomic site that isn't a Jetpack site under the hood.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That makes sense, updated it here @tyxla.

@@ -49,6 +51,9 @@ function getStore() {

describe( 'fetchModuleList', () => {
test( "Ensure we're NOT calling fetchModuleList for simple sites", async () => {
isWpcomAtomic = false;
isJetpack = false;
Copy link
Member

Choose a reason for hiding this comment

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

If we always declare these in the beginning of the test, we might as well remove the let call and move them here as consts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure if I understood your suggestion since we're using these variables inside mockStore, and if we declare them constants, we can't change them on other tests.

Copy link
Member

Choose a reason for hiding this comment

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

I see, that makes sense. Let's leave them as they are then 👍

@paulopmt1 paulopmt1 merged commit 2f7e74e into trunk May 29, 2024
11 checks passed
@paulopmt1 paulopmt1 deleted the fix/remove-unnecessary-jetpack-call branch May 29, 2024 13:55
@github-actions github-actions bot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants