[jifty-devel] A slow pony and suboptimal loops

Agent Zhang agentzh at gmail.com
Sun Dec 17 10:02:45 EST 2006


Hello,

Jifty's pony is terribly slow when loading the model admin page for
nontrivial apps. I've chasing the bottle-neck tonight and have found
it is located at:

   admin/fragments/list/list
       admin/fragments/list/view
            <% $update->form_field($argument, render_mode => 'read') %>
                 Jifty::Action::form_field
                     Jifty::Web::Form::Field::""
                          Jifty::Web::Form::Select::render_value

The render_value method takes a lot of time when processing columns
referring to external tables. I've seen Jesse checked in this
implementation in rev 1059:

    http://svn.jifty.org/index.cgi/jifty/revision?rev=1059

To be more specific, the following loop takes too much time:

        my @value = grep { $_->{value} eq $value }
                        @{ $self->action->available_values($self->name) };
        $value = $value[0]->{display} if scalar @value;

I can see two potential ways to optimize this:

1. Optimize the loop itself by using List::Util::first or something like that.
2. Skip the loop completely if there's no "name" column in the target table.

Any ideas?

Cheers,
Agent


More information about the jifty-devel mailing list