Skip to content

Live Mode in Team is maxing out CPU #1011

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

Closed
sairam opened this issue Jul 27, 2018 · 8 comments
Closed

Live Mode in Team is maxing out CPU #1011

sairam opened this issue Jul 27, 2018 · 8 comments

Comments

@sairam
Copy link
Contributor

sairam commented Jul 27, 2018

🐛 bug report

Sandbox UI is maxing out my CPU causing slowness in UI and productivity.

Your Environment with material-ui

Software Name/Version
Сodesandbox create-react-app
Browser Chrome 68.0.3440.75
Operating System Mac OS X High Sierra

Google Chrome Helper is using up 400% of CPU when I edit a sandbox when its part of a 'Team Sandbox'. It does not consume as much CPU (works fine) when its part of 'My Sandboxes'.
I have a team member who is invited but not accepted the invite.

I understand the rationale behind not being able to disable 'Live' if a project is part of a team in order to avoid code conflicts and unable to use 'VIM' mode in Team settings.

I have profiled CPU usage and it points to the Babel Transpiler javascript file. I am able to reproduce this issue with my current private project (in my account). Let me know if you need any additional information.

@CompuIves
Copy link
Member

Heh, this is an interesting issue. My one explanation could be that it could maybe because of live operations being sent around, but then the babel-transpiler should not be maxing out. Really weird, the babel transpiler nor the bundler knows the difference between live/non-live env.

I'll do some debugging on this!

@CompuIves
Copy link
Member

Does it happen from the start? And does it happen when you're idle or only while editing?

@sairam
Copy link
Contributor Author

sairam commented Jul 28, 2018 via email

@sairam
Copy link
Contributor Author

sairam commented Jul 28, 2018

Hi @CompuIves ,

You can find it here https://codesandbox.io/s/km040v81o7

The minimal reproducible project is when I add 2 dependencies (@material-ui/core and @material-ui/icons) to a React Project.

Once you I start editing and then in idle, the CPU continues to be maintained at the highest possible value.

@CompuIves
Copy link
Member

Okay, found the issue! This was super interesting.

We have fs in the babel transpiler, for babel plugin/preset support. Because of this, the transpiler needs access to the file system of the sandbox. However, the transpiler is in a web worker. That's why we eagerly sync all files over from the original main thread to the worker. In this case this was a lot of files, as material-ui includes its icons as well.

So, I made it non-eager. Meaning that it will only start syncing when a custom babel plugin or preset is required. This should improve memory usage/performance for all sandboxes!

@CompuIves
Copy link
Member

It will be live in ~15 min.

@sairam
Copy link
Contributor Author

sairam commented Jul 28, 2018 via email

@CompuIves
Copy link
Member

It's live! You might need to invalidate your service worker to see the changes immediately.

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

2 participants