Hi Lee

You're not the first to hit this issue, and what you've spotted in the  
init files is indeed the cause. As to why it's happening:
* By default, Rails lazily loads models when you first reference them
* Which means Model.subclasses returns nothing if you've not  
referenced any existing subclasses
* Thinking Sphinx needs to know about subclasses when you have a STI  
setup, to return the right search results
* So, TS forces a load of all models, to ensure Model.subclasses is  
accurate.

And because in development mode, the environment is reloaded on every  
request, so are the models via TS.

If you don't have any STI models, then the quick fix is to comment out  
the lines in rails/init.rb and init.rb. It's becoming enough of an  
issue that I really should add a setting in Thinking Sphinx to disable  
this, since I'm sure the majority of people don't use STI. I will try  
to get to that soon.

Hope this helps.

-- 
Pat

On 04/06/2009, at 4:11 PM, Lee Fyock wrote:

>
> Hi--
>
> The developers on our team recently started complaining about the
> speed of server responses and launching script/console in development
> mode. Some quick work with "git bisect" indicated it was my commit
> that switched us from acts_as_solr to thinking_sphinx.
>
> Some benchmarking shows that launching script/console goes from around
> 6.2 seconds to 9.8 seconds when the TS plugin is installed and the
> define_index calls in two models are present. Commenting out the
> define_index calls has no effect; it's the mere presence of the plugin
> that causes the slowdown.
>
> When running script/server, the slowdown happens _before_ Rails is
> invoked, so the time doesn't show up in the "Completed in 0.01884 (53
> reqs/sec)" benchmark lines. Our site makes a number of Ajax calls, so
> the price per page load is fairly high.
>
> This indicates to me that TS is doing something on every request that
> is slowing things down. From a brief perusal of the two init.rb files,
> I'm guessing that TS is re-scanning the models directory, which is
> rather large for our site, and reloading all the models.
>
> Since TS is a plugin, I don't expect it to pick up changes without
> restarting the server, so what's the best way to avoid this
> performance hit?
>
> I've never written a plugin, so I'm unfamiliar with the ins and outs
> of load-time and dispatch-time hooks.
>
> This isn't a concern in production mode, I think, but boy, do we
> developers complain when things slow down. :-)
>
> I appreciate any help. Thanks,
> Lee
>
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Thinking Sphinx" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/thinking-sphinx?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to