Acl increase speed

I profiling my web application with xhprof and see next picture: (image link)

xhprof report

Acl is very slowly

Who have ideas or solutions increase speed this place?

Thanks for all

edited Apr '17

Could you first post some example of acl actual code causing a problem? Looks like you have some many allow/deny and many roles which inherit themselves, this can cause it i think.

I have 10 roles 1->2->3->4->etc every inherits previous

    public function getAcl()
        $config = require PH_APP_PATH . '/config/acl.php';
        $roles = [];
        $acl = new AclList();

        /* @var UsersRoles[] $users_roles */
        $users_roles = UsersRoles::query()->orderBy('id')->execute();

        foreach ($users_roles as $users_role) {
            $roles[$users_role->role] = new Role($users_role->role);

            if (!empty($users_role->parent)) {
                $acl->addRole($users_role->role, $users_role->parent);
            } else {

        foreach ($roles as $role) {
            foreach ($config[$role->getName()] as $resource => $action) {
                $acl->addResource(new Resource($resource), $action);

                $acl->allow($role->getName(), $resource, $action);

        return $acl;
edited Apr '17

Yea but last one inherits 9 previous, second last one inherits 8 previous etc, this is why so many calls.

I would just cache this stuff with roles/roleInherits perhaps.

You definietly should use cache, check out cache usage in Vokuro ACL: