简体   繁体   English

代码更改后,Rails 开发服务器需要很长时间才能重新加载

[英]Rails dev server takes a long time to reload after codes changes

I swear that this was not an issue in the past and I can't pinpoint when I think this changed.我发誓这在过去不是问题,我无法确定我认为这种情况何时发生了变化。 In my local development environment if I make ANY changes to my models / controllers my server takes at least 20-30 seconds to reload and respond to requests.在我的本地开发环境中,如果我对我的模型/控制器进行任何更改,我的服务器至少需要 20-30 秒来重新加载和响应请求。 This is Rails 5.2.3 and Thin 1.7.2.这是 Rails 5.2.3 和 Thin 1.7.2。 I don't recall it ever being this slow before.我不记得以前这么慢。 FYI I have config.cache_classes = false already which is the obvious culprit.仅供参考,我已经有config.cache_classes = false了,这是明显的罪魁祸首。

Any ideas here?这里有什么想法吗?

I've been fighting with this issue for some time and I seem to have found two solutions worth trying.我已经为这个问题奋斗了一段时间,我似乎找到了两个值得尝试的解决方案。 I run Rails 7.0.4 and Puma 6.0.我运行 Rails 7.0.4 和 Puma 6.0。

After debugging with rack-mini-profiler , I noticed that Thread::Mutex#synchronize was very slow.使用rack-mini-profiler调试后,我注意到Thread::Mutex#synchronize非常慢。 ~30 seconds. ~30 秒。 So I figured lowering the number of Puma threads might help.所以我认为减少 Puma 线程的数量可能会有所帮助。 It improved but didn't completely solve the problem for me.它有所改善,但并没有完全解决我的问题。

To run Puma single-threaded, I put the following in my Procfile:为了单线程运行 Puma,我将以下内容放入我的 Procfile 中:

RAILS_MIN_THREADS=0 RAILS_MAX_THREADS=1 bin/rails s -p 3000

The problem I was experiencing seems to be more directly related to this bug in Puma 6.0.0, as discussed here: https://github.com/ElMassimo/vite_ruby/issues/299 andhttps://github.com/jumpstart-pro/jumpstart-pro-rails/issues/475我遇到的问题似乎与 Puma 6.0.0 中的这个错误更直接相关,如下所述: https://github.com/ElMassimo/vite_ruby/issues/299https://github.com/jumpstart- pro/jumpstart-pro-rails/issues/475

Downgrading to 5.6.5 completely eliminated the issue, and I was able to return to multi-threaded Puma.降级到 5.6.5 完全解决了这个问题,我能够回到多线程 Puma。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM