[ 
https://issues.apache.org/jira/browse/SENTRY-1937?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16163437#comment-16163437
 ] 

Alexander Kolbasov commented on SENTRY-1937:
--------------------------------------------

This was the code path that was very hot in a high-load scenario. A lot of 
threads were sitting in {{pm.retrieve}} in 

{code}
  private Set<MSentryRole> getMSentryRolesByGroupName(final String groupName)
      throws Exception {
    return tm.executeTransaction(
        new TransactionBlock<Set<MSentryRole>>() {
          public Set<MSentryRole> execute(PersistenceManager pm) throws 
Exception {
            Set<MSentryRole> roles;

            //If no group name was specified, return all roles
            if (groupName == null) {
              roles = new HashSet<>(getAllRoles(pm));
            } else {
              String trimmedGroupName = groupName.trim();
              MSentryGroup sentryGroup = getGroup(pm, trimmedGroupName);
              if (sentryGroup == null) {
                throw noSuchGroup(trimmedGroupName);
              }
              roles = sentryGroup.getRoles();
            }
            for (MSentryRole role: roles) {
              pm.retrieve(role); // Here
            }
            return roles;
          }
        });
  }
{code}

> Optimize performance for listing sentry roles by group name
> -----------------------------------------------------------
>
>                 Key: SENTRY-1937
>                 URL: https://issues.apache.org/jira/browse/SENTRY-1937
>             Project: Sentry
>          Issue Type: Improvement
>          Components: Sentry
>    Affects Versions: 2.0.0
>            Reporter: Alexander Kolbasov
>            Assignee: Arjun Mishra
>
> It seems that the most common request is listing sentry roles by group name, 
> so this is a very hot path. It is important to optimize its performance, 
> especially in the presence of many roles.
> [~arjunmishra13] FYI.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to