Open Bug 528230 Opened 15 years ago Updated 15 years ago

Bugzilla::FlagType->grant_list, which is used when usemenuforusers=1, is slow

Categories

(Bugzilla :: Attachments & Requests, defect)

defect
Not set
minor

Tracking

()

People

(Reporter: mockodin, Unassigned)

Details

Bugzilla::FlagType->grant_list is very slow owing to it loading every active user object in the profiles table... even when it knows it shouldn't needed to check them at all.

Currently the look up logic is as follows:

Bugzilla::FlagType->grant_list
    @allusers = Bugzilla->user->get_userlist
      FOREACH user in @allusers
        $user_obj = Bugzilla->user
          user_obj->can_set_flag
             return (!$flag_type->grant_group_id
            || $self->in_group_id($flag_type->grant_group_id)) ? 1 : 0;

As you can see if $flag_type->grant_group_id is not set in the first place then we always return true, problem is we knew this before ever calling the user object. So why do the extra steps?

A Quick performance comparison:

**Using Unaltered Bugzilla::FlagType->grant_list**

Apache 2.2, Mod_perl, Windows 2008, MSSQL, usemenuforusers = true, 2500 users, slow server = roughly a 2 minute load times for show_bug.cgi

**Using ALTERED Bugzilla::FlagType->grant_list**

<begin insert into gran_list after 'my @allusers ...'>
    # If you can't request it then whats the point
    return () unless $self->{is_requesteeble};
    # If it is not grantable then anyone can set it
    return \@allusers unless $self->{'grant_group_id'};
</end insert>

Apache 2.2, Mod_perl, Windows 2008, MSSQL, usemenuforusers = true, 2500 users, slow server = roughly 6-7 seconds load times for show_bug.cgi

Similarly Bugzilla::User->can_request_flag should return true out of hand if grant_group_id is NOT set based on the current code.

While usemenuforusers is NOT recommended for large user bases there is no reason it should not be optimized where possible.
As you say, this method is and should only be used when usemenuforusers = 1, i.e. when there are only a few tens of users max. This makes it not a top priority bug. If there are trivial fixes to implement to avoid spending too much time when no grant group is set, I'm still fine to take them.
Assignee: create-and-change → attach-and-request
Severity: normal → minor
Component: Creating/Changing Bugs → Attachments & Requests
Summary: Bugzilla::FlagType->grant_list is very slow → Bugzilla::FlagType->grant_list, which is used when usemenuforusers=1, is slow
You need to log in before you can comment on or make changes to this bug.