Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Fix performance: delete activation from nav bar, user profile, admin overview page#43591

Merged
mrnugget merged 8 commits intomainfrom
mrn+pj/remove-activation
Oct 28, 2022
Merged

Fix performance: delete activation from nav bar, user profile, admin overview page#43591
mrnugget merged 8 commits intomainfrom
mrn+pj/remove-activation

Conversation

@mrnugget
Copy link
Contributor

@mrnugget mrnugget commented Oct 28, 2022

This removes this thing

screenshot_2022-10-28_12 03 20@2x

from

  • global nav bar
  • users profile page
  • admin analytics overview page

Why?

Customer reported severe impact on database performance after upgrading from 3.43.2 to 4.0.1. The reason for the performance regression is a change made in #40674: the user { usageStats } GraphQL query would now hit PostgreSQL instead of Redis to get the usage stats.

Here is the code path in 3.43.2 for user { usageStats }: https://github.com/sourcegraph/sourcegraph/blob/fd7599b9cbf3e80334a6167763b3c74ee9cddf9c/cmd/frontend/internal/usagestatsdeprecated/usage_stats.go#L42-L43

Here it is in 4.0+ https://github.com/sourcegraph/sourcegraph/blob/41e19f207038b4822dc9ebb052eb857e3dae9103/internal/usagestats/usage_stats.go#L110-L136

The SQL queries run by the latter have bad performance because they do multiple queries over one of the biggest tables we have: event_logs. Some of the performance problems with that have been addressed in https://github.com/sourcegraph/sourcegraph/pull/43564 and https://github.com/sourcegraph/sourcegraph/pull/43582.

Big problem: these queries are run on every page load, due to the withActivation wrapper we had around the Layout component. That wrapper would load the usageStatistics for the currently-logged-in user on every page load to display that onboarding checklist at the top.

On the customer's instance this resulted in slow queries piling up in the database, pinning CPU usage at 100% and exhausting the database connection limits.

After discussing the issue in Slack, we decided to remove this component altogether, since we deem the risk low: the component has been unchanged in 3 years, it's unloved and unowned, it has performance implications, and it most likely doesn't have any effect on user onboarding.

Test plan

  • Existing tests

App preview:

Check out the client app preview documentation to learn more.

@cla-bot cla-bot bot added the cla-signed label Oct 28, 2022
@mrnugget mrnugget requested a review from a team October 28, 2022 11:53
@sourcegraph-bot
Copy link
Contributor

sourcegraph-bot commented Oct 28, 2022

Codenotify: Notifying subscribers in CODENOTIFY files for diff 68ad8ff...ab70cca.

Notify File(s)
@fkling client/search-ui/src/input/toggles/Toggles.tsx
client/search/src/helpers.ts
client/web/src/search/helpers.test.tsx
client/web/src/search/helpers.tsx
client/web/src/search/home/SearchPage.tsx
client/web/src/search/home/SearchPageInput.tsx
client/web/src/search/input/SearchNavbarItem.tsx
client/web/src/search/results/StreamingSearchResults.tsx
@limitedmage client/search-ui/src/input/toggles/Toggles.tsx
client/web/src/search/helpers.test.tsx
client/web/src/search/helpers.tsx
client/web/src/search/home/SearchPage.tsx
client/web/src/search/home/SearchPageInput.tsx
client/web/src/search/input/SearchNavbarItem.tsx
client/web/src/search/results/StreamingSearchResults.tsx
@philipp-spiess client/jetbrains/webview/src/search/input/JetBrainsToggles.tsx
@vdavid client/jetbrains/webview/src/search/input/JetBrainsToggles.tsx

Copy link
Contributor

@kopancek kopancek left a comment

Choose a reason for hiding this comment

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

LGTM :godmode:

@sg-e2e-regression-test-bob
Copy link

sg-e2e-regression-test-bob commented Oct 28, 2022

Bundle size report 📦

Initial size Total size Async size Modules
-0.78% (-22.71 kb) 🔽 -0.12% (-17.67 kb) 🔽 0.04% (+5.04 kb) 0.28% (+2) 🔺

Look at the Statoscope report for a full comparison between the commits ab70cca and 68ad8ff or learn more.

Open explanation
  • Initial size is the size of the initial bundle (the one that is loaded when you open the page)
  • Total size is the size of the initial bundle + all the async loaded chunks
  • Async size is the size of all the async loaded chunks
  • Modules is the number of modules in the initial bundle

@malomarrec malomarrec self-requested a review October 28, 2022 12:55
Copy link
Contributor

@umpox umpox left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is fine to remove given the impact this is having, but just tagging @sourcegraph/iam for visibility. We might want to consider an alternative UI if this has more importance for site admins. (Non blocking)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kopancek already approved and @pjlast was on the Zoom call with me when I removed it :)

We should tag @erzhtor @thenamankumar and @rrhyne here so they're aware. @malomarrec also gave his approval below, so we're good to go.

Copy link
Contributor

@malomarrec malomarrec left a comment

Choose a reason for hiding this comment

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

Great!
We (growth team), when we have capacity, plan to reinstate this in a better (and not buggy) form.
Thanks for removing the current version!

@mrnugget
Copy link
Contributor Author

Build green. Running main-dry-run now.

Copy link
Member

@eseliger eseliger left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for doing that so quickly!

BolajiOlajide pushed a commit that referenced this pull request Oct 28, 2022
…overview page (#43591)

This removes the "search code, find ref, search symbol" onboarding checklist from

- global nav bar
- users profile page
- admin analytics overview page

Customer reported severe impact on database performance after upgrading from 3.43.2 to 4.0.1. The reason for the performance regression is a change made in #40674: the `user { usageStats }` GraphQL query would now hit PostgreSQL instead of Redis to get the usage stats.

Here is the code path in 3.43.2 for `user { usageStats }`: https://github.com/sourcegraph/sourcegraph/blob/fd7599b9cbf3e80334a6167763b3c74ee9cddf9c/cmd/frontend/internal/usagestatsdeprecated/usage_stats.go#L42-L43

Here it is in 4.0+ https://github.com/sourcegraph/sourcegraph/blob/41e19f207038b4822dc9ebb052eb857e3dae9103/internal/usagestats/usage_stats.go#L110-L136

The SQL queries run by the latter have bad performance because they do multiple queries over one of the biggest tables we have: `event_logs`. Some of the performance problems with that have been addressed in https://github.com/sourcegraph/sourcegraph/pull/43564 and https://github.com/sourcegraph/sourcegraph/pull/43582.

Big problem: **these queries are run on every page load, due to the `withActivation` wrapper we had around the `Layout` component.** That wrapper would load the `usageStatistics` for the currently-logged-in user on every page load to display that onboarding checklist at the top.

On the customer's instance this resulted in slow queries piling up in the database, pinning CPU usage at 100% and exhausting the database connection limits.

After discussing the issue in Slack, [we decided to remove this component altogether](https://sourcegraph.slack.com/archives/C03TGHH1S3V/p1666951569092379?thread_ts=1666747586.140109&cid=C03TGHH1S3V), since we deem the risk low: the component has been unchanged in 3 years, it's unloved and unowned, it has performance implications, and it most likely doesn't have any effect on user onboarding.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants