Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

performance issues with RoleHierarchy #57322

Open
@simonjamain

Description

@simonjamain

Symfony version(s) affected

7.1.1

Description

TheRoleHierarchy::buildRoleMap() can be slow when there is a big hierrachy to build.

For context, in our project (https://gitlab.com/incubateur-territoires/france-relance/silab/silab-front) we have a dynamic role tree that rely extensively on the symfony implementation ofRoleHierarchy.

After using a profiler we saw that it took 9 seconds to build our role map (~4s in production).

The use ofarray_shift in the folowing line is the culprit :

while ($role =array_shift($additionalRoles)) {

We changed it for anarray_pop which is known to have abetter complexity and we dropped from ~9s to ~50ms in dev env (RoleHierarchy::buildRoleMap() execution time).

AFAIK thearray_shift behavior is not needed in that loop andarray_pop return the same elements in the role map.

How to reproduce

You can time the execution of the main buildRoleMap loop (either with a profiler or with your logger) with the originalarray_shift and with thearray_pop

Possible Solution

replace the use ofarray_shift witharray_pop in the folowing line

while ($role =array_shift($additionalRoles)) {

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp