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

High CPU usage #320

Open
2 of 3 tasks
schickling opened this issue Dec 6, 2017 · 53 comments
Open
2 of 3 tasks

High CPU usage #320

schickling opened this issue Dec 6, 2017 · 53 comments

Comments

@schickling
Copy link
Collaborator

schickling commented Dec 6, 2017

This issue pertains to:

  • GraphQL Playground - Electron App
  • GraphQL Playground
  • GraphQL Playground Middleware

What OS and OS version are you experiencing the issue(s) on?

MacOS High Sierra

What version of graphql-playground(-electron/-middleware) are you experience the issue(s) on?

v1.3.6 (web)

What is the expected behavior?

The Playground should be friendly to my CPU 🤔

What is the actual behavior?

In some scenarios the CPU goes all crazy (sometimes above 80%). I couldn't exactly pin it down to a specific reproducible case but it's happening quite frequently. I suspect the Playground is "trapped" in some kind of infinite loop.

image

What steps may we take to reproduce the behavior?

Unfortunately I couldn't yet find a clear way to reproduce it. Would be great if other people can add more information!

Update:

I suspect it has something to do with errors (for example when the server returns an error)

@vincenzo
Copy link
Contributor

I confirm this issue.

@marktani
Copy link
Contributor

To me this happened when I was running a query that was returning a lot of data.

Can everyone share some information when it happened to them? 🙂 This might help pinning down the problem.

@marktani marktani mentioned this issue Jan 1, 2018
7 tasks
@marktani
Copy link
Contributor

marktani commented Jan 1, 2018

This is one potential cause: #356.

@schickling
Copy link
Collaborator Author

schickling commented Jan 1, 2018

@marktani the high CPU only occurs with the HTTP middleware. #356 seems to be related to the Electron app

@vincenzo
Copy link
Contributor

vincenzo commented Jan 1, 2018

@schickling It happens for me (express middleware).

@huv1k
Copy link
Collaborator

huv1k commented Jan 5, 2018

Can everybody share at least little bit info how to get to this state, because i tried to reproduce it and no luck.

@marktani
Copy link
Contributor

marktani commented Jan 5, 2018

So far I have not been able to reliably reproduce this. Some potential causes

  • many Playgrounds are open (many browser tabs)
  • many Playground tabs are open
  • working with big schemas
  • working with big data
  • when queries run into an error

@vincenzo
Copy link
Contributor

vincenzo commented Jan 5, 2018

The times I’ve seen it happening I had one or two (max) playgrounds open; I had a few tabs open; some queries may have errored a few times before getting it right. Small schema.

@kambing86
Copy link

kambing86 commented Feb 8, 2018

having this issue as well in v1.4.3 Mac version,

at the workplace selection screen, the GraphQL Playground helper is constantly at >20% cpu usage
after opening the workplace, cpu usage raised to ~60%
after opening schema, my 2015 Macbook Pro started spinning up the fan, cpu usage raised to ~100%

don't blame on electron, I'm using a lot of electron apps like VSCode and GitKraken, all work just fine
I highly suspect that someone sneaked in some codes to do mining

@huv1k
Copy link
Collaborator

huv1k commented Feb 8, 2018

@kambing86 No there is no mining you can see it in network tab..

@vincenzo
Copy link
Contributor

vincenzo commented Feb 9, 2018

Right, I might have an additional insight on this. I am developing a GraphQL server with graphl-yoga, so naturally I am using Playground. Locally, I run this server via Lando, so in Docker containers. When Playground goes and uses the CPU at 200+% (it really happened), so does Docker.

I haven't yet checked network traffic etc., to see what's actually going between the two, if anything...

@emibloque
Copy link

Hi!
Beforehand, thanks for this awesome project!

I'm having this issue too, with the electron app. The CPU usage raises only when the app window is visible.
I removed locally all the CSS animations and the usage (showing the New Workspace window) dropped from ~30% to ~2%.
Removing only the SVG that shows when the application is loading makes a difference on the usage.

I don't have context on the project, but I think this could be one of the main issues.

@huv1k
Copy link
Collaborator

huv1k commented Feb 11, 2018

Yea, i was digging little bit inside and playground is rendering like crazy, even that you are not doing anything. You can see it in performance graph:

@timsuchanek
Copy link
Member

Thanks for the insights everyone! We're working on the playground performance and will probably have a new release this or next week with some improvements :)

@vincenzo
Copy link
Contributor

I can definitely replicate what I wrote in my last comment: as soon as I open PG in Chrome and run a query, the Docker container running the server starts eating 160+% of CPU, and so does PG. If I do what @emibloque said, and just switch tab, the Chrome's CPU usage halves, but the Docker container's one remains the same. The only way to calm the storm is to close the tab where PG is running.

@atitoa93
Copy link

This issue happens to me as well.
OS: macOS High Sierra
Chrome: Version 64.0.3282.167 (Official Build) (64-bit)
Middleware: graphql-yoga

Every time I open the playground the CPU start increasing whatever the size of the schema.

@vincenzo
Copy link
Contributor

Any news on this, @timsuchanek? This is starting to become a serious issue for me, as it also affects the docker container where Yoga is running, and the machine starts struggling under the excessive CPU usage.

@mirkonasato
Copy link

Noticed the same issue on macOS High Sierra after creating a very simple server with graphql-yoga: shortly after I open the Playground in the latest Chrome my laptop fan starts running. Same thing with the Electron version. Interestingly it doesn't happen with the version hosted at graphqlbin.com.

@huv1k
Copy link
Collaborator

huv1k commented Feb 28, 2018

I think i figured out what is problem, i will try to make fix for it 👍 Yea i got it playground cpu usage varies with number of rendered editors so we can just render active editor to reduce cpu usage :)

@timsuchanek
Copy link
Member

@HuVik I'm working on a fix for that, which is also including reducing the number of editors. So no need from your side to work on that :)

@nickluger
Copy link

Fans start spinning as soon as i open playground in Chrome, (Version 64.0.3282.186) Mac OS High Sierra(10.13.3)
Slow down after a while but, can spike out of a sudden.
Have many extensions but happens in incognito mode, too.

@kambing86
Copy link

any update on this? seems like the recent release still suffering, any insight so that we can help to figure out and solve this?

@blackxored
Copy link
Contributor

This also happens on the Electron app for me.

@vincenzo
Copy link
Contributor

@timsuchanek I still get this issue with the latest PG in Yoga.

@iamgmd
Copy link

iamgmd commented May 23, 2018

same here, the playground is pretty much unusable at the moment. I think rendering seems to be the issue as scrolling in a decent size json output is sluggish and not very nice to work with. On large json output (203814 lines), the browser becomes pretty much unresponsive or even gives up. Using something like Altair has no problem, runs the query and the json output in approx 4s and scrolling is smooth. I am using 1.14.1 version of graphql-yoga. Just wondering if this is going to be fixed or should I turn off playground and try and incorporate something else?

@timsuchanek
Copy link
Member

Thanks for your comment @iamgmd ! We can't give a clear timeline right now, but it is definitely something we will work on in the coming weeks.
After a quick look into Altair I'm pretty sure that we can accomplish the same speed as they're also using Codemirror for the result view.

@timsuchanek timsuchanek reopened this May 23, 2018
@timsuchanek
Copy link
Member

@iamgmd your comment was so important to use, that we just released a new version of the react and electron app with a performance that matches the performance of the original GraphiQL and Altair 🙂

You can download the latest electron app here: https://github.com/prismagraphql/graphql-playground/releases/tag/v1.5.9

@vincenzo
Copy link
Contributor

@timsuchanek Middleware express coming soon for Yoga?

@iamgmd
Copy link

iamgmd commented May 25, 2018

Ah m8, that is sweet and I can confirm that it renders much faster and scrolling is smooth on my 203814 line example. Job well done and now very usable :-)

You might be surprised to know I did still manage to break it when running a really really large query (1.6 million lines - 45MB). The result is that the query doesn't display all the lines, only about 3/4 of them and therefore the output is not complete. Altair did manage to display of all the lines but not surprising was sluggish when scrolling. That being said though, it is better to have all the lines whilst sacrificing performance in this use-case.

image

@moltar
Copy link

moltar commented Nov 12, 2018

I think this happens on high volume subscriptions. The results area gets a lot of results and probably the front end code and/or component is not very optimized. I cannot even scroll to told results, yet the whole browser tab becomes unresponsive.

@chebotaevroman
Copy link

"graphql-yoga": "^1.17.4"

100% cpu usage on just open web app
macOs, google chrome

@freshtonic
Copy link

freshtonic commented Jun 26, 2019

This is still a problem, why is this issue closed? Opening the playground in the browser causes my mac to slow down noticeably even when not running any queries.

Edit: this is with an empty query pane. Literally launching the playground and doing nothing will cause my machine to become laggy.

@johhansantana
Copy link

johhansantana commented Jul 10, 2019

Same as @freshtonic web playground slows down my mac (using http://localhost:4466 with an empty query pane)

Downloading the app didn't help either:
Screen Shot 2019-07-10 at 4

EDIT
I think it has something to do with local development with Docker, when I open a playground that's connected to prisma.io test servers the cpu seems normal?

@yoshiakis yoshiakis reopened this Jul 11, 2019
@yoshiakis yoshiakis added bug/1-repro-available A reproduction exists and needs to be confirmed. kind/bug labels Jul 11, 2019
@freshtonic
Copy link

I think it has something to do with local development with Docker, when I open a playground that's connected to prisma.io test servers the cpu seems normal?

FWIW, I'm not using Docker.

@freshtonic
Copy link

freshtonic commented Jul 11, 2019

I can confirm that increasing the query refresh interval in the settings works around the issue. But even with the default settings it doesn't seem like something that should slow down my machine significantly.

@huv1k
Copy link
Collaborator

huv1k commented Jul 11, 2019

Yes, it's because of schema pooling. This feature runs only on local from the default you can adjust it in settings by changing schema option https://github.com/prisma/graphql-playground#properties

@johhansantana
Copy link

Yes, it's because of schema pooling. This feature runs only on local from the default you can adjust it in settings by changing schema option https://github.com/prisma/graphql-playground#properties

I have put "schema.polling.enable" to false and this seems to fix the issue, at least for me.

@moltar
Copy link

moltar commented Jul 12, 2019

Can confirm what @johhansantana said. Disabling polling fixed the CPU issue.

I think this may happen when live reload is ON and doing quick iterations. At least, this was my use case.

@igorvuleta
Copy link

igorvuleta commented Sep 9, 2019

Just for refference if someone gets stuck with huge memory consumption. By code first approach it's needed to turn of the polling and the query refresh interval, I wasn't avare of that and my API started to consume more and more memory without an code explanation, simply the polling and refreshing the schema was fault, since it's a reversed approach to development.

E: And Playgrounds requiers almost 250MB of memory more then graphiql, to keep a schema alive?

@richard-fairthorne
Copy link

richard-fairthorne commented Dec 30, 2019

Screen Shot 2019-12-30 at 8 43 50 AM

I have 10 lines of server code, no backing DB, and my macbook fan spins like mad after i open playground in chrome. I have to close it every minute or so, or my machine overheats and crashes.

It's using a lot of GPU. I thought it was a trojan bitcoin miner at first.

@richard-fairthorne
Copy link

richard-fairthorne commented Dec 30, 2019

@huv1k @johhansantana Disabling schema polling worked! THANK YOU!

@adrianoresende
Copy link

Disabling schema polling worked! =)

Maybe It is related #653 (comment)

@filipe-q
Copy link

Setting "schema.polling.enable" to false also worked for me

@johannesmutter
Copy link

My graphics card’s fans ran full speed when schema polling is enabled. This should be disabled by default, until it’s fixed.
I looked into what’s the cause, and it seems it’s this tiny animation of the pulsing dot next to the address bar.

Disabling schema polling helps, but so does removing that little animation.

schema-polling-animation

schema-polling-animation2

schema-polling-disabled

@meastes
Copy link

meastes commented Apr 19, 2021

I ran into this as well. If you want to hide the dot, you can add this style to the page. This custom style will persist through reloads of your server as well.

[title="Polling Schema"] {
  display: none;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests