[Pkg-owncloud-commits] [owncloud] 66/223: drastic speedup for nested ldap groups

David Prévot taffit at moszumanska.debian.org
Sun Jun 22 01:54:07 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository owncloud.

commit 767aa4e35ff4d8c9bd61996b15b286a86a9f92db
Author: macjohnny <estebanmarin at gmx.ch>
Date:   Thu Jun 12 09:41:23 2014 +0200

    drastic speedup for nested ldap groups
    
    add a function getUserGroupIds for retrieving group ids instead of group objects. this significantly improves performance when using many (nested) groups.
    
    Changes a function call in getUserGroups to only retrieve group ids instead of objects.
    this change significantly improves performance when using owncloud with many groups, e.g. nested ldap hierarchy (1.2.840.113556.1.4.1941), since getUserGroups gets called in oc_share::getItems, which is needed for every page request.
    in my particular case, it took more than 10s to load the calendar page and more than 6s to load the file page.
    this was in an environment with 100 user groups (nested) per user. The performance was bad due to the following call stack:
    self::getManager()->getUserGroups($user)
      - getGroupObject() (executed for every group!)
         - groupExists() (resulting in many ldap-requests)
    since the groups are loaded from ldap, it is unnecessary to check whether the group exists or not.
---
 lib/private/group.php         |  7 +------
 lib/private/group/manager.php | 12 ++++++++++++
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/lib/private/group.php b/lib/private/group.php
index 8dc3812..bd9e3d3 100644
--- a/lib/private/group.php
+++ b/lib/private/group.php
@@ -187,12 +187,7 @@ class OC_Group {
 	public static function getUserGroups($uid) {
 		$user = self::$userManager->get($uid);
 		if ($user) {
-			$groups = self::getManager()->getUserGroups($user);
-			$groupIds = array();
-			foreach ($groups as $group) {
-				$groupIds[] = $group->getGID();
-			}
-			return $groupIds;
+			return self::getManager()->getUserGroupIds($user);
 		} else {
 			return array();
 		}
diff --git a/lib/private/group/manager.php b/lib/private/group/manager.php
index dae6443..3613c75 100644
--- a/lib/private/group/manager.php
+++ b/lib/private/group/manager.php
@@ -182,6 +182,18 @@ class Manager extends PublicEmitter {
 		$this->cachedUserGroups[$uid] = array_values($groups);
 		return $this->cachedUserGroups[$uid];
 	}
+	/**
+	 * @param \OC\User\User $user
+	 * @return array with group names
+	 */
+	public function getUserGroupIds($user) {
+		$groupIds = array();
+		foreach ($this->backends as $backend) {
+			$groupIds = array_merge($groupIds, $backend->getUserGroups($user->getUID()));
+			
+		}
+		return $groupIds;
+	}
 
 	/**
 	 * get a list of all display names in a group

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list