-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Raphael,

I've seen this kind of issues before. I suspect the problem lies in
the the way Hobo creates the table, running a lot of code for every
element in every row. I would recommend:

- - Decide if you really need 300 elements per page. I usually work with
50 or so, and it's a huge difference.

- - Create your own "table-plus" with your own helper. Just enclose a
manual table with a div class="table-plus" and you'll get the looks
and it'll probably much faster.

- - There are a lot of complex benchmarking solutions, but I usually
enjoy this hack:
  START = Time.now
  # Here it goes the code you are benchmarking
  logger.info ((Time.now - START)*1000).to_s + 'ms since START'

- - Use page caching if the content is not changing a lot.




Not related to your question, but other important tips for performance
and user experience:

- - In development mode, Rails 3.2 with Active Reload makes a huge
difference. As you are in Rails 3.0 I would try the rails-dev-boost
gem. It has some glitches but makes development mode usable!

- - Cache assets, fingerprinting them so the browser doesn't ask for
them. This has been made much easier and faster in Rails 3.2, but Hobo
is not ready just yet.

- - Load javascript after the page has loaded (lazy loading). I'm using
right now something like this, and you win something like 200ms in
Firefox:

<extend tag="page">
  <old-page merge>
    <scripts: replace/>
    <append-body:>
      <script defer type="text/javascript">
      (function() {
        function getScript(url,success){
          var script=document.createElement('script');
          script.src=url;
          var head=document.getElementsByTagName('head')[0],
              done=false;
          script.onload=script.onreadystatechange = function(){
            if (!done){
              if (!this.readyState || this.readyState == 'loaded' ||
this.readyState == 'complete'){
              done=true;
              success();
              script.onload = script.onreadystatechange = null;
              head.removeChild(script);
            }}
          };
          head.appendChild(script);
        }
        setTimeout(function() {
          getScript('/assets/application.js',function(){
            // YOUR CODE GOES HERE AND IS EXECUTED AFTER JQUERY LOADS
          });
        },250);
      })();
      </script>
    </append-body:>
  </old-page>
</extend>

Regards,
Ignacio

El 13/07/12 01:44, Raphael Sofaer escribió:
> Hi Matt, Vivek,
> 
> Here's some more information.  The app is running in production
> mode, although I'd like it to be a reasonable speed in dev mode
> also, for development.  Dev mode now is up to twice as slow.
> There's tons of free memory and cpu on the machine.  Rails and hobo
> versions: rails (3.0.5) hobo (1.3.0)
> 
> I've set the log level to debug to get the queries for the
> particular index page that I'm looking at, the class names aren't
> secret:
> 
> Processing by PipettePullsController#index as HTML PipettePull Load
> (1.0ms)  SELECT `pipette_pulls`.* FROM `pipette_pulls` LIMIT 300
> OFFSET 0 SQL (0.6ms)  SELECT COUNT(*) FROM `pipette_pulls` CACHE
> (0.0ms)  SELECT `pipette_pulls`.* FROM `pipette_pulls` LIMIT 300 
> OFFSET 0 StereotaxicInjection Load (15.1ms)  SELECT
> `stereotaxic_injections`.* FROM `stereotaxic_injections` WHERE 
> (`stereotaxic_injections`.pipette_pull_id IN (4,[snip, there are
> about 250 ids in here],303)) TracerType Load (0.5ms)  SELECT
> `tracer_types`.* FROM `tracer_types` WHERE (`tracer_types`.`id` IN 
> (6,7,8,10,17,9,11,12,16,24,18,28,27,26,19,21,22,20,23,29,30,33,31,32,34,35))
>
> 
CACHE (0.0ms)  SELECT COUNT(*) FROM `pipette_pulls`
> Rendered pipette_pulls/index.dryml (9238.8ms) Completed 200 OK in
> 9371ms (Views: 9239.8ms | ActiveRecord: 17.2ms)
> 
> The queries are insignificant in the total time, and it doesn't
> seem like there are any hidden relations being loaded.  Here's the
> controller code for the action:
> 
> hobo_model_controller auto_actions :all def index hobo_index
> :per_page => 300, :include => {:stereotaxic_injections => 
> :tracer_type} end
> 
> I put the nested include in a couple days ago, which sped it up 
> marginally, and reduced drastically the number of queries. I
> noticed that the model has a view_permitted?(field) method which
> just returns true.  I'm not sure if that's run for every
> user/model combination, would that be a big performance hit?
> 
> Thanks again, Raphael
> 
> On Wednesday, July 11, 2012 5:59:30 PM UTC-4, Matt jones wrote:
> 
> 
> On Jul 11, 2012, at 5:45 PM, Raphael Sofaer wrote:
> 
>> Hi Hobo users,
>> 
>> I'm a developer with rails experience working at a neuroscience
> lab, and we have a legacy hobo app which is ridiculously slow.
> Some of our index pages take 10 seconds to load.  All the time is
> in view rendering, effectively none in ActiveRecord.  How can I
> figure out what's wrong here?  Most of the places I would but
> benchmarking functions are wrapped up in hobo methods, so I'm not
> sure what to do.  The slowest page uses hobo_index in the
> controller, and collection and table_plus in the dryml file.  Are
> those a recipe for disaster?   I don't think there's any page that
> has a sub-second load time, though.
> 
> The first thing I'd check is the server - is it running in 
> production mode? The behavior you've described sounds a lot like
> the result of an app running in development mode. Also check to see
> if the server is overloaded (swapping, etc) as some of the old
> defaults for gems like Passenger specified an unreasonable number
> of processes for small machines.
> 
> Note that some of the timing stuff (especially on older Rails)
> will not always give sensible results; for instance, a default
> index action will only actually load records when they're used on
> the page, causing the view to get charged most of AR's time as
> well.
> 
> Ping me off-list if you'd like another set of eyes on the code.
> 
> --Matt Jones
> 
> -- You received this message because you are subscribed to the
> Google Groups "Hobo Users" group. To view this discussion on the
> web visit 
> https://groups.google.com/d/msg/hobousers/-/hjBnu6V8hsYJ. 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/hobousers?hl=en.

- -- 
Ignacio Huerta Arteche
http://www.ihuerta.net
Teléfono: 0034 645 70 77 35
Email realizado con software libre
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAlAAZa4ACgkQBPlUJ6RHaOR7PACff2OQNs0wNIPUyXKTjV8E5FYv
pA8AnRVxXU6mU4GJw0fBkPsRA3xcwPmz
=xkaX
-----END PGP SIGNATURE-----

-- 
You received this message because you are subscribed to the Google Groups "Hobo 
Users" 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/hobousers?hl=en.

Reply via email to