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

Sharp library causing high cpu usage on Windows #117

Closed
sinankeskin opened this issue Apr 11, 2020 · 10 comments · Fixed by #118
Closed

Sharp library causing high cpu usage on Windows #117

sinankeskin opened this issue Apr 11, 2020 · 10 comments · Fixed by #118

Comments

@sinankeskin
Copy link
Contributor

sinankeskin commented Apr 11, 2020

Hi.

First of all, thank you for this addon. Really useful.

On Windows if I delete dist folder and run ember app with ember s, nodejs using high cpu.

I investigated and found out that the reason is the Sharp library. Basically I guess Sharp process keeps open itself, never kills after success. And after the uninstall your addon high cpu usage is gone.

For the record, if I close the app (without the delete dist folder) and rerun again this issue is not happening. I guess skips the creating file.

And also this issue is not happening in Linux.

Thank you.

@jrjohnson
Copy link
Owner

Thanks for letting me know @sinankeskin. I don't have a windows machine to debug this on, but the first step is to test just sharp without this addon and see if the problem is with sharp itself or the implementation here.

If you can extract the specifics from generate-icons.js and create that reproduction it would be super helpful. If you get stuck anywhere you can ping me in Ember discord @jrjohnson.

@sinankeskin
Copy link
Contributor Author

I've tested and here is the result.

Seems like this is not a Sharp library nor your implementation issue.

When I run first time, below line never resolve completely. Somehow hangs.
But only happening first time, not after. What I mean by that, If I restart windows and run again it's happening but after that everythings just fine.

return RSVP.all(promises);

If I change the

return RSVP.all(promises);

to

return Promise.all(promises);

this issue is not happening.

Also if I change the code like

RSVP.all(promises).then((values) => {
  console.log(values);
}).catch(err => {
  console.log(err);
});

this issue is not happening.

Bottom line seems like this is an RSVP library issue.

Thanks for your attention. Closing.

@jrjohnson
Copy link
Owner

Looks like good sleuthing! I'd be happy to merge a PR that removes the RSVP dependency here and uses straight Promise.all which looks like it is valid for all versions of Node back to 0.12.

@sinankeskin
Copy link
Contributor Author

Thank you.

@void-mAlex
Copy link

hello, I've upgraded to v4.0.1 but I'm still seeing the high CPU usage and I can confirm it goes away if I remove the plugin
using node v12.14.0

@sinankeskin
Copy link
Contributor Author

Hi @void-mAlex

Could you please test with sharp_test and check if the node process waits or exits? Please test the same script 2 or more times.

Thanks.

@sinankeskin sinankeskin reopened this Apr 15, 2020
@void-mAlex
Copy link

void-mAlex commented Apr 15, 2020

just tested and all except 1 run waited and never completed
did around ~20 tests with the included svg and my own same fail rate

@sinankeskin
Copy link
Contributor Author

sinankeskin commented Apr 16, 2020

Hi @void-mAlex

Could you please test with sharp_test again? git clone again please.

I couldn't reproduce the issue. Not in debugger nor usual run.

My node version is 12.16.2

Thanks.

@void-mAlex
Copy link

void-mAlex commented Apr 16, 2020

I've updated to node 12.16.2
and it still hangs on all runs and I get a bunch of warning for not being able to load fonts
sharp:12916
edit: started it with node --inspect-brk and I can't see it doing anything (ran profiler for 30 seconds nothing shows up), not sure how to get into what the compiled version of sharp does. Any pointers on that would be greatly appreciated, or if there is anything else I can do to help

@sinankeskin
Copy link
Contributor Author

I can (hopefully) confirm that this is a Sharp issue and I believe this line is the responsible.

https://github.com/lovell/sharp/blob/70e730bb677b80879d7578a4fdb881ad34afec60/lib/output.js#L767

sharp.pipeline is a native (compiled) method which unfortunately seems like on Windows it has an issue (hangs). Feel free to open an issue on Sharp library.

Also that's why I couldn't reproduce on Linux.

Sorry for the dirturb @jrjohnson and thank you @void-mAlex

I'm closing.

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

Successfully merging a pull request may close this issue.

3 participants