samueleaton / sentry

Build/Runs your crystal application, watches files, and rebuilds/restarts app on file changes
MIT License
286 stars 27 forks source link

Huge CPU load #23

Open msa7 opened 6 years ago

msa7 commented 6 years ago

Thanks for the useful shard.

I run three Sentry, each in the docker container.

  1. Watch JS, CSS to rebuild
  2. Watch CR, ECR to restart the web server
  3. Watch CR, ECR to rerun specs

I have huge CPU load 2018-03-24_06-21-55

Maybe Senty should use kqueue or similar, like rerun gem?

samueleaton commented 6 years ago

thanks for the feedback. I will investigate this.

Just to verify, does running your containers without sentry drastically reduce the hyperkit cpu?

msa7 commented 6 years ago

does running your containers without sentry drastically reduce the hyperkit cpu?

yes

I found a workaround. Run sentry on Mac. On file change rerun docker container, like this:

bin/sentry \
-w "./src/**/*.cr" -w "./src/**/*.ecr" \
-b "" -r "docker-compose" --run-args "run --rm test crystal spec --debug"

Please also consider https://github.com/samueleaton/sentry/pull/25

samueleaton commented 6 years ago

so sentry is not a cpu hog when being run directly on the host? its only when running in docker?

samueleaton commented 6 years ago

What is the processor and ram on your Mac? I am running a few sentries locally and hyperkit is staying below 20% (usually bellow 10%).

KCErb commented 5 years ago

I'm having the same issue, getting 300%+ (4 cores) with sentry running in the container. (lucky framework uses sentry for watch).

Related: https://github.com/docker/for-mac/issues/1094

Though for me a factory reset doesn't solve the problem.

To answer your question to msa7:

MacBook Pro (Retina, 15-inch, Mid 2014) 2.5 GHz Intel Core i7 16 GB 1600 MHz DDR3

Docker has access to: 4 CPUs 6 GiB of Memory 1 GiB of Swap

I suppose I could increase the Swap? For now planning on running watch from host and triggering a recompile in the container from there like msa7.

KCErb commented 5 years ago

OK a few notes:

  1. I thought I was using Sentry, but Lucky has its own Sentry .. so sorry, I wasn't directly working with your library.
  2. All of the watch libraries are relying on similar principles which docker for mac really struggles with. At the end of the day, there are filesystem issues that I'm not qualified to speak on. A loop asking for file info (like modified timestamps) is going to be bad in docker for mac until they fix it.
  3. I solved my problems with docker-sync. I'll be doing a blog write up on this eventually, if there is any interest out there, I'll post a link to it here when it is written.
samueleaton commented 5 years ago

@KCErb yes please let me know what you find.