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

Asynchronously populate counts for unreviewed validation errors and validated URLs in admin menu and dashboard widget #5772

Closed
maciejmackowiak opened this issue Jan 10, 2021 · 10 comments · Fixed by #5900
Assignees
Labels
Groomed P1 Medium priority Performance WS:Perf Work stream for Metrics, Performance and Optimizer
Milestone

Comments

@maciejmackowiak
Copy link

Feature description

We have noticed a huge performance impact from the query used for populating unread AMP validated urls/validation errors count.
It sometimes adds 0.3-0.5s to wp-admin page load.
Could you please consider moving it to cron job?


Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

Implementation brief

QA testing instructions

Demo

Changelog entry

@maciejmackowiak
Copy link
Author

Here is an example how much time this query can take:
obraz

@westonruter
Copy link
Member

I don't think the cron job will work because it needs to be live. In other words, if you have just 1 validated URL left that has an unreviewed error, you'll see a (1) next to Validated URLs as well as some other number next to Error Index (x). When you save update the status of a validation error from Unreviewed to Reviewed, the result is that these two numbers should decrement right away. It should be the same behavior as the bubbles next to Comments when there are unmoderated comments, and Plugins when there are updates available. These update immediately upon moderation and update respectively.

What could be done is to introduce a REST API endpoint for fetching the counts count of validated URLs containing unreviewed errors, as well as the count of unreviewed errors in the error index. If this were available, then we could do a request for those fields to then populate the menu item accordingly. Upon the first page load, the fetched numbers could be stored in localStorage to populate immediately upon page load to then potentially be updated if there has been a change.

@westonruter westonruter added Performance WS:Perf Work stream for Metrics, Performance and Optimizer labels Jan 12, 2021
@westonruter
Copy link
Member

Note the counts themselves are cached in transients per #3222, #3666, and #5343. However, when an update is made to a validated URL then the cache is invalidated.

@maciejmackowiak Are you seeing this slow query with every page load, or just after AMP validated data has been changed?

@westonruter
Copy link
Member

The two places the counts occur are:

  1. The admin menu:
    image
  2. The At a Glance widget on the dashboard:
    image

@archon810
Copy link

We have Query Monitor enabled on production for only admins, and this amp query is there all the time throughout the day. It's definitely not every time I load wp admin, but I notice it enough times for it to become frustrating. We have a busy site with lots of posts getting published and updated daily.

@archon810
Copy link

Ajax all the things!

@kmyram kmyram added Groomed P1 Medium priority labels Jan 19, 2021
@westonruter
Copy link
Member

We can also consider making the request only when we need. So if the user is not even on an AMP settings screen, we can skip making the requests until the user opens the AMP admin submenu.

@pierlon pierlon self-assigned this Feb 11, 2021
@westonruter westonruter added this to the v2.1 milestone Feb 11, 2021
@westonruter westonruter changed the title Consider moving the Validated URLs/new validation errors to cron job. Asynchronously populate counts for unreviewed validation errors and validated URLs in admin menu and dashboard widget Feb 17, 2021
@archon810
Copy link

@westonruter 🎉

@westonruter
Copy link
Member

@westonruter 🎉

Forwarding to @pierlon!

@pierlon pierlon self-assigned this Apr 27, 2021
@pierlon
Copy link
Contributor

pierlon commented Apr 27, 2021

QA Passed

  • The "At a Glance" widget is no longer shown:

image

  • Validation counts are only asynchronously retrieved when the AMP menu is hovered over:
20210427191708.mp4
  • Validation counts are asynchronously retrieved when the AMP menu is open:
20210427192308.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Groomed P1 Medium priority Performance WS:Perf Work stream for Metrics, Performance and Optimizer
Projects
None yet
5 participants