Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX 11577 performance issues with large list of groups #11578

Open
wants to merge 1 commit into
base: 5
Choose a base branch
from

Conversation

beerbohmdo
Copy link
Contributor

@beerbohmdo beerbohmdo commented Jan 27, 2025

Description

If you have many groups you can no longer edit a member in the admin.

Manual testing steps

As this is a performance issue, I am not sure howto create a unittest for this. But here is a task to create a massive amount of groups:

<?php

use SilverStripe\Dev\BuildTask;
use SilverStripe\ORM\DB;
use SilverStripe\Security\Group;

class GroupCreationTask extends BuildTask
{
    public function run($request): void
    {
        DB::query('TRUNCATE "Group"');
        DB::query('TRUNCATE "Permission"');

        Group::singleton()->requireDefaultRecords();

        $conn = DB::get_conn();
        $conn->transactionStart();

        $start = hrtime(true);

        for ($i = 0; $i < 3000; $i++) {
            if (($i % 100) == 0) {
                $conn->transactionEnd();
                $conn->transactionStart();

                $end = hrtime(true);
                $t = ($end - $start) / 1e9;

                printf("%d - %fs\n", $i, $t);

                $start = hrtime(true);
            }

            $parentGroup = Group::create();
            $parentGroup->Code = 'group_' . $i;
            $parentGroup->Title = 'Group ' . $i;
            $parentGroup->write();

            for ($j = 0; $j < 5; $j++) {
                $group = Group::create();
                $group->Code = 'group_' . $i . '_' . $j ;
                $group->Title = 'Group ' . $i . ' ' . $j;
                $group->ParentID = $parentGroup->ID;
                $group->write();
            }
        }

        $conn->transactionEnd();

        $end = hrtime(true);
        $t = ($end - $start) / 1e9;

        printf("%d - %fs\n", $i, $t);
    }
}

Issues

Pull request checklist

  • The target branch is correct
  • All commits are relevant to the purpose of the PR (e.g. no debug statements, unrelated refactoring, or arbitrary linting)
    • Small amounts of additional linting are usually okay, but if it makes it hard to concentrate on the relevant changes, ask for the unrelated changes to be reverted, and submitted as a separate PR.
  • The commit messages follow our commit message guidelines
  • The PR follows our contribution guidelines
  • Code changes follow our coding conventions
  • This change is covered with tests (or tests aren't necessary for this change)
  • Any relevant User Help/Developer documentation is updated; for impactful changes, information is added to the changelog for the intended release
  • CI is green

@beerbohmdo beerbohmdo force-pushed the 11577-slow-group-tree branch from 120baae to c8b41b0 Compare January 27, 2025 10:17
@beerbohmdo beerbohmdo changed the title 11577 Fix performance issues with large list of groups FIX 11577 performance issues with large list of groups Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant