painfully slow development mode on large project

I'm working on a pretty large (and still growing) project and the bigger it gets the slower development mode becomes, but runs really fast in production mode. So I assume the slowdown at the beginning of each request is caused by the fact that it reloads everything. It currently has about 85 models, 75 controllers, and 11k Code LOC.

It's becoming really painful. For instance, I'm working on a page that involves a lot of ajax calls. One call shows the following in the development.log:

Completed in 0.38060 (2 reqs/sec) | Rendering: 0.02327 (6%) | DB: 0.06884 (18%)

But firebug timed it at 5.38 seconds. :frowning: So that means reloading my

What web server? It would seem that Rails is done with the request pretty quickly... so the extra time is coming from somewhere else.

Any chance you're using webrick? I could see that happening with a lot of ajax as webrick can only handle one request at a time...

Our app is about 43,000 lines and has 832 classes and it's not that slow... we're running litespeed for development...

Tony Buser wrote:

Philip Hallstrom wrote:   

Any chance you're using webrick? I could see that happening with a lot of ajax as webrick can only handle one request at a time...      I'm using mongrel. Regular pages take about 2-3 seconds longer to load then what is shown in development.log. The slow down occurs at the beginning of the request before anything even shows up in the log. It's like I hit a link, count to 3, then BAM lots of stuff shows up in log and page comes in. On pages that might do multiple ajax calls at the same time, it does tend to take longer. Is mongrel able to handle more then one request at a time?    Not exactly (the Rails processing can't be done concurrently, but serving files in <rails_app>/public can). If there is such a delay with near 0 CPU usage, you may want to use strace to see what syscall Mongrel is waiting the result for, it might be a DNS request, a file opening, ... This should point you in the right direction.

Lionel

As it happens, Josh Goebel just released a plugin to deal with this very problem:

http://svn.techno-weenie.net/projects/plugins/dev_mode_performance_fixes/

Why don't we only reload the files when they have actually changed? Store the file names and their last modified time and then stat all the files before every request... if any are newer, kill the objects they originally defined and let the Dependency auto-loading code reload the objects from disk.

People are reporting anywhere between "4x" and "almost as fast as production" speed improvements.

-faisal

Faisal N Jawdat wrote:

As it happens, Josh Goebel just released a plugin to deal with this
very problem:

http://svn.techno-weenie.net/projects/plugins/ dev_mode_performance_fixes/

It catched my eyes too, but I have a project with more LOC, models and controllers than Tony's project and webrick on a 1.06GHz Centrino Duo is fast enough for me (nearly all actions take less than 1s and most are around 0.3s, 3-4 whole seconds seems odd to me unless he uses something like a Pentium MMX or less for the server), so I don't think his problem is class reloading (or he must have a pretty peculiar code). Won't hurt to try though.

Lionel

Philip Hallstrom wrote:

Any chance you're using webrick? I could see that happening with a lot of ajax as webrick can only handle one request at a time...

I'm using mongrel. Regular pages take about 2-3 seconds longer to load then what is shown in development.log. The slow down occurs at the beginning of the request before anything even shows up in the log. It's like I hit a link, count to 3, then BAM lots of stuff shows up in log and page comes in. On pages that might do multiple ajax calls at the same time, it does tend to take longer. Is mongrel able to handle more then one request at a time?

One Rails request at a time. Static is threaded...

Our app is about 43,000 lines and has 832 classes and it's not that slow... we're running litespeed for development...

How much of a delay for each request do you experience in development mode?

Hardly any. Obviously it takes longer to load since it's dev and we're not caching anything, but it still comes up...

Someone else mentioned DNS... that might be worth looking into as well.

-philip