On Mon, Aug 6, 2012 at 1:56 PM, Pat Allan <[email protected]> wrote: > Hi Luis > > It wouldn't be too tricky to use Riddle to query Sphinx directly - AR models > are only queried for the sake of string facets (and that's something I'm > looking at working around when I implement facets in my rewrite of Thinking > Sphinx). > > Feel free to give it a shot, but if you get stuck let me know and I'll piece > some code together to help. >
Hello Pat, I found that querying sphinx directly still give me a fast response, but was Ruby processing of the response the main issue. After isolating the query I wanted, I wrote some benchmarks and started to profile Riddle responses and noticed 14K calls to Riddle::Client::Response#next_int which took 26% (0.32 sec) of the time of every call. That combined with Riddle::Client#attribute_from_type who took another 0.58 secs, combined later with iteration over attributes and placing those results into an array of hashes resulted in the poor performance I was experiencing. Decided to took a simple approach and rewrote Riddle::Client::Response class entirely in C, no longer using String#pack/unpack to read bytes from the string but instead looked at libsphinxclient for unpacking these values. After doing that I went from 0.8 secs per query to 0.3 secs, still having Riddle::Client#attribute_from_type and Array#each, Hash#[] and Hash#[]= taking a lot of time parsing such responses (inside Riddle::Client#run command) I'm still testing this out (not on production yet) but once we have it will look for approval to open-source it. Regards, -- Luis Lavena AREA 17 - Perfection in design is achieved not when there is nothing more to add, but rather when there is nothing more to take away. Antoine de Saint-Exupéry -- 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.
