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

Could Sentry javascript performance be improved? #2233

Closed
1 of 3 tasks
OZZlE opened this issue Sep 10, 2019 · 15 comments
Closed
1 of 3 tasks

Could Sentry javascript performance be improved? #2233

OZZlE opened this issue Sep 10, 2019 · 15 comments

Comments

@OZZlE
Copy link

OZZlE commented Sep 10, 2019

Important Details

How are you running Sentry?

  • On-Premise docker [Version xyz]
  • Saas (sentry.io)
  • Other [briefly describe your environment]

Description

When measuring mobile 4G performance using Google Chrome Audit (Lighthouse) removing Sentry javascript seems to improve our performance score around 3% on initial page load.

Chrome also reports (if you switch on all logging) in console:

bundle.min.js:2 [Violation] 'setInterval' handler took 239ms
bundle.min.js:2 [Violation] 'setInterval' handler took 51ms
bundle.min.js:2 [Violation] 'setInterval' handler took 117ms
bundle.min.js:2 [Violation] 'setInterval' handler took 58ms

We are using version 5.2.1

Steps to Reproduce

  1. Place Sentry.io javascript (at the very end of body - after React) on a React website with infinite scroll and scroll to load a lot of content
  2. Watch Chrome console (with all logging enabled)
@markstory markstory transferred this issue from getsentry/sentry Sep 10, 2019
@kamilogorek
Copy link
Contributor

kamilogorek commented Sep 10, 2019

@OZZlE is there a chance you have such an app laying around somewhere, and I could use it to profile the issue?

@OZZlE
Copy link
Author

OZZlE commented Sep 20, 2019

@kamilogorek I am not sure if I am allowed to share it publicly, in any case setTimeout/setInterval should be avoided as much as possible - not always possible, but interested as to why Sentry needs to use it?

@OZZlE
Copy link
Author

OZZlE commented Sep 20, 2019

Skärmklipp 2019-09-20 15 57 32

Skärmklipp 2019-09-20 15 58 14

From Google Page speed. I can send you an url privately perhaps.

(p.s. nobody will ever know what 'Other' is...)

@rtymchyk
Copy link

Consider code splitting sentry out and loading it at runtime when an error is reported.

@pats
Copy link

pats commented Oct 28, 2019

image
Guys, it's getting worse every day ... currently it looks like some kind of regression issue

@pats
Copy link

pats commented Oct 28, 2019

I'm guessing but maybe issue was introduced here c3b7940 ?

@OZZlE
Copy link
Author

OZZlE commented Oct 29, 2019

Consider code splitting sentry out and loading it at runtime when an error is reported.

??? can't exactly put try-catch around entire bundle.. even then how would sentry pick it up if it wasn't loaded before? also the try-catch would prevent any error reported unless you throw it again after loading sentry..?

@kamilogorek
Copy link
Contributor

how would sentry pick it up if it wasn't loaded before?

We have lazy-loading solution explained here: https://docs.sentry.io/platforms/javascript/#lazy-loading-sentry

@rtymchyk
Copy link

Consider code splitting sentry out and loading it at runtime when an error is reported.

??? can't exactly put try-catch around entire bundle.. even then how would sentry pick it up if it wasn't loaded before? also the try-catch would prevent any error reported unless you throw it again after loading sentry..?

Add global handlers yourself, via window.onerror (and similar handler for uncaught promises). On error, load the module, initialize sentry (disabling their global handler integration), and bubble the exception directly to sentry.

@intellix
Copy link

intellix commented Nov 20, 2019

Speaking of code splitting. I feel like the bundle is large at 57.7kb. Does this include the Sentry.showReportDialog({ eventId }) that we don't want/use?

Screenshot 2019-11-20 at 12 51 15

@kamilogorek
Copy link
Contributor

Does this include the Sentry.showReportDialog({ eventId }) that we don't want/use?

No, it lives outside the SDK and is dynamically included when necessary.

@dryoma
Copy link

dryoma commented Jun 15, 2020

Hi everyone,
I'd like to join in the request as well :)

As for

We have lazy-loading solution explained here: https://docs.sentry.io/platforms/javascript/#lazy-loading-sentry

We are using the lazy loader, and Sentry's bundle is by far the biggest slowdown for us, at least according to Google (especially prominent on mobile)
image

@sod
Copy link
Contributor

sod commented Aug 6, 2020

you have to remove the Breadcrumb Integration as it's a) bugged anyway and b) shatters your performance. See #2125

@OZZlE
Copy link
Author

OZZlE commented Aug 6, 2020

Say that your entire website consists of One JS App for example in React. To catch js errors one could wrap the entire app in index.js with a try { } catch(e) { // send to Sentry }

In that case Sentry would only need to provide a tiny js API to send errors to it and you can just use the Sentry "Control panel" part to track errors :)

I have implemented this but still have all the overhead of Sentry js.. also the documentation is not clear about how I send the stack trace or where the error actually originated from.. Maybe what I missed is to after catching and loading up sentry I should throw the error again.

I do not load Sentry.io js at all before there is an actual error this way. Problem is I've lost the stack trace and where the errors are coming from in code. But my suggestion above might fix this.

Seems also like React "warnings" are for some reason caught like this so most of the time Sentry.io js is loaded anyway as it can be pretty hard to always track mounted/unmounted async stuff in React.

@AbhiPrasad
Copy link
Member

#3208 will have fixed some performance concerns, and #2707 tracks the bundle size concerns. Additional information can be found here #2817, our plans for a major bump of the SDK, which should help address some concerns around tree shakability and bundle.

Closing this issue for repo maintenance, but if there are any other performance concerns, please let us know!

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

No branches or pull requests

8 participants