Skip to content
This repository has been archived by the owner on Jun 2, 2022. It is now read-only.

chore: Improve overall performance #418

Merged
merged 2 commits into from
Mar 25, 2022
Merged

chore: Improve overall performance #418

merged 2 commits into from
Mar 25, 2022

Conversation

tlgimenes
Copy link
Contributor

@tlgimenes tlgimenes commented Mar 24, 2022

What's the purpose of this pull request?

#295 added login functionality. This, however, introduced an unnecessary re-render of the whole app. This PR removes the need for this re-render, thus reducing TBT and increasing overall performance

How does it work?

#295 made the return type of the person query to be StorePerson!. This means that the query result of person returns the following value for the anonymous user:

{
  "id": "",
  "email": "",
  "givenName": "",
  "familyName": ""
}

This, in turn, is different from the default user session, passed in the context provider as null. This mismatch in values, caused the session to be reset for the anonymous user, causing an unnecessary re-render.

To fix this issue, I made the api return null for the person query when executed by an anonymous user. This matches the default value from the session, this not triggering a re-render. All changes are performed on this PR at faststore

An evidence can be seen below were the first image shows the ProductGallery component being rendered twice (due to session being reset) and the second image shows the absence of this re-render after the proposed fix.

image

image

How to test it?

Make sure everything works as before and ProductGallery renders once.

Make sure to delete any pre-stored value in indexedDB

Checklist

  • CHANGELOG entry added

@vtex-sites
Copy link

vtex-sites bot commented Mar 24, 2022

Preview is ready

This pull request generated a Preview

👀   Preview: https://preview-418--base.preview.vtex.app
🔬   Go deeper by inspecting the Build Logs
📝   based on commit aca45d3

@netlify
Copy link

netlify bot commented Mar 24, 2022

Deploy Preview for basestore ready!

Name Link
🔨 Latest commit 7e906cb
🔍 Latest deploy log https://app.netlify.com/sites/basestore/deploys/623dcc176b4a190008970ca0
😎 Deploy Preview https://deploy-preview-418--basestore.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@gatsby-cloud
Copy link

gatsby-cloud bot commented Mar 24, 2022

Gatsby Cloud Build Report

basestore

🎉 Your build was successful! See the Deploy preview here.

Build Details

View the build logs here.

🕐 Build time: 15m

Performance

Lighthouse report

Metric Score
Performance 💚 95
Accessibility 💚 100
Best Practices 💚 100
SEO 💚 93

🔗 View full report

CHANGELOG.md Outdated Show resolved Hide resolved
@igorbrasileiro
Copy link
Contributor

Hey, you changed nothing. The purpose is to add just the mark hoc? @tlgimenes

Copy link
Contributor

@filipewl filipewl left a comment

Choose a reason for hiding this comment

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

Following @igorbrasileiro's question, I assume this PR is missing the part where the faststore package is updated to reflect the improvements.

@tlgimenes
Copy link
Contributor Author

Following @igorbrasileiro's question, I assume this PR is missing the part where the faststore package is updated to reflect the improvements.

Yes, this part was missing, I had only done it locally for extracting the images. Now we have the full version

@igorbrasileiro
Copy link
Contributor

Results after run 20 psi tests via api
Page result - https://base.vtex.app/

Metric Mean Standard deviation
Cumulative Layout shift (CLS) 0.00 0.00
First Contentful Paint (FCP) 1823.92 72588.98
First Contentful Paint 3g (FCP) 3398.24 159152.47
Largest Contentful Paint (LCP) 1918.23 11251.40
Time to Interactive (TTI) 4095.18 218320.64
Total Blocking Time (TBT) 722.31 66249.29
Performance score 0.802 0.005419
JavaScript Execution Time 2221.49 349446.83
Speed Index 2512.07 66531.67

Page result - https://sfj-3321c99--base.preview.vtex.app/

Metric Mean Standard deviation
Cumulative Layout shift (CLS) 0.00 0.00
First Contentful Paint (FCP) 1408.29 4461.97
First Contentful Paint 3g (FCP) 2592.67 74760.67
Largest Contentful Paint (LCP) 1935.69 4314.01
Time to Interactive (TTI) 3523.45 0.01
Total Blocking Time (TBT) 515.45 7805.14
Performance score 0.855 0.000525
JavaScript Execution Time 1685.06 27049.33
Speed Index 2034.19 10235.46

Copy link
Contributor

@lariciamota lariciamota left a comment

Choose a reason for hiding this comment

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

Nice!! 🚀

package.json Outdated Show resolved Hide resolved
@tlgimenes tlgimenes merged commit aca45d3 into master Mar 25, 2022
@tlgimenes tlgimenes deleted the chore/api branch March 25, 2022 14:54
@tlgimenes tlgimenes added the performance Improvements to performance label Mar 31, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
performance Improvements to performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants