[jifty-devel] A slow pony and suboptimal loops

Agent Zhang agentzh at gmail.com
Sun Dec 17 21:18:56 EST 2006

On 12/18/06, Jesse Vincent <jesse at bestpractical.com> wrote:
> > 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;
> Is it that available_values isn't being cached? If so, would precaching
> it help?

Jesse, are you sure you really want to cache it? I've checked the size
of the array returned by available_values:

    WARN - Count: 529

It's exactly as huge as my sessions table! Moreover, the whole
rander_values sub doesn't do anything useful at all in my situation
because there's no column named "name" in my sessions table.

I believe Jifty should do something smarter here. available_values
shouldn't return everything in a database table IMHO. Database tables
can be extremely large.

Currently loading my message's admin page takes me 21 sec (not
counting the loading time of css and js) on my Pentium IV machine
((3.0 GHz, 512 MB RAM)). Right, it's terrible. Benchmark shows that it
only takes 7 sec if skipping the useless loop completely.

Yes, 7 sec is still too long. But it's much much more acceptable than
21 sec. You know, demonstrating the Jifty pony in front of my
instructor really really drove me mad. ;-)


More information about the jifty-devel mailing list