subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stef...@apache.org
Subject svn commit: r1772440 - in /subversion/branches/authzperf/subversion/libsvn_repos: authz.c authz.h
Date Sat, 03 Dec 2016 09:40:09 GMT
Author: stefan2
Date: Sat Dec  3 09:40:09 2016
New Revision: 1772440

URL: http://svn.apache.org/viewvc?rev=1772440&view=rev
Log:
On the authzperf branch:
Remove the local cache of filtered authz trees and simply keep only the
latest one.  Now, the authz struct only contains the references to the
3 authz model levels - full model, filtered tree and lookup context.

A proper cache for the filtered trees will be added shortly.

* subversion/libsvn_repos/authz.h
  (AUTHZ_FILTERED_CACHE_SIZE): No longer needed.
  (svn_authz_t): Replace the local USER_RULES cache with a simple reference
                 to a FILTERED tree.

* subversion/libsvn_repos/authz.c
  (get_filtered_tree): Update, dropping the cache iteration.

Modified:
    subversion/branches/authzperf/subversion/libsvn_repos/authz.c
    subversion/branches/authzperf/subversion/libsvn_repos/authz.h

Modified: subversion/branches/authzperf/subversion/libsvn_repos/authz.c
URL: http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_repos/authz.c?rev=1772440&r1=1772439&r2=1772440&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_repos/authz.c (original)
+++ subversion/branches/authzperf/subversion/libsvn_repos/authz.c Sat Dec  3 09:40:09 2016
@@ -1377,51 +1377,43 @@ get_filtered_tree(svn_authz_t *authz,
                   apr_pool_t *scratch_pool)
 {
   apr_pool_t *pool;
-  apr_size_t i;
+  node_t *root;
 
   /* Search our cache for a suitable previously filtered tree. */
-  for (i = 0; i < AUTHZ_FILTERED_CACHE_SIZE && authz->user_rules[i]; ++i)
+  if (authz->filtered)
     {
       /* Is this a suitable filtered tree? */
-      if (!matches_filtered_tree(&authz->user_rules[i], repos_name, user))
-        continue;
-
-      /* LRU: Move up to first entry. */
-      if (i > 0)
+      if (matches_filtered_tree(authz->filtered, repos_name, user))
         {
-          authz_user_rules_t *temp = authz->user_rules[i];
-          memmove(&authz->user_rules[1], &authz->user_rules[0],
-                  i * sizeof(temp));
-          authz->user_rules[0] = temp;
-        }
+          if (*path)
+            *path = init_lockup_state(authz->filtered->lookup_state,
+                                      authz->filtered->root,
+                                      *path);
 
-      if (*path)
-        *path = init_lockup_state(authz->user_rules[0]->lookup_state,
-                                  authz->user_rules[0]->root,
-                                  *path);
+          return authz->filtered;
+        }
 
-      return authz->user_rules[0];
+      /* Drop the old filtered tree before creating a new one. */
+      svn_pool_destroy(authz->filtered->pool);
+      authz->filtered = NULL;
     }
 
-  /* Cache full? Drop last (i.e. oldest) entry. */
-  if (i == AUTHZ_FILTERED_CACHE_SIZE)
-    svn_pool_destroy(authz->user_rules[--i]->pool);
+  /* Global cache lookup.  Filter the full model only if necessary. */
+  pool = svn_pool_create(authz->pool);
+  root = create_user_authz(authz->full, repos_name, user, pool,
+                           scratch_pool);
 
   /* Write a new entry. */
-  pool = svn_pool_create(authz->pool);
-  authz->user_rules[i] = apr_palloc(pool, sizeof(*authz->user_rules[i]));
-  authz->user_rules[i]->pool = pool;
-  authz->user_rules[i]->repository = apr_pstrdup(pool, repos_name);
-  authz->user_rules[i]->user = user ? apr_pstrdup(pool, user) : NULL;
-  authz->user_rules[i]->root = create_user_authz(authz->full,
-                                                 repos_name, user, pool,
-                                                 scratch_pool);
-  authz->user_rules[i]->lookup_state = create_lookup_state(pool);
+  authz->filtered = apr_palloc(pool, sizeof(*authz->filtered));
+  authz->filtered->pool = pool;
+  authz->filtered->repository = apr_pstrdup(pool, repos_name);
+  authz->filtered->user = user ? apr_pstrdup(pool, user) : NULL;
+  authz->filtered->lookup_state = create_lookup_state(pool);
+  authz->filtered->root = root;
   if (*path)
-    init_lockup_state(authz->user_rules[i]->lookup_state,
-                      authz->user_rules[i]->root, *path);
+    init_lockup_state(authz->filtered->lookup_state, root, *path);
 
-  return authz->user_rules[i];
+  return authz->filtered;
 }
 
 

Modified: subversion/branches/authzperf/subversion/libsvn_repos/authz.h
URL: http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_repos/authz.h?rev=1772440&r1=1772439&r2=1772440&view=diff
==============================================================================
--- subversion/branches/authzperf/subversion/libsvn_repos/authz.h (original)
+++ subversion/branches/authzperf/subversion/libsvn_repos/authz.h Sat Dec  3 09:40:09 2016
@@ -41,20 +41,6 @@ extern "C" {
  *   Authz and global group file parsing
  */
 
-/* Number of (user, repository) combinations per authz for which we can
- * cache the corresponding filtered path rule trees.
- *
- * Since authz instance are per connection and there is usually only one
- * repository per connection, 2 (user + anonymous) would be sufficient in
- * most cases.  Having 4 adds plenty of headroom and we expect high locality
- * in any case.
- *
- * ### This number will be far too low if/when the parsed authz info
- *     becomes shared between multiple sessions.
- */
-#define AUTHZ_FILTERED_CACHE_SIZE 4
-
-
 /* A dictionary of rules that are specific to a particular
    (user, repository) combination. */
 typedef struct authz_user_rules_t authz_user_rules_t;
@@ -172,9 +158,9 @@ struct svn_authz_t
   /* The parsed and pre-processed contents of the authz file. */
   authz_full_t *full;
 
-  /* A cache of rules filtered for a particular user.
-     These will be generated on-demand. */
-  authz_user_rules_t *user_rules[AUTHZ_FILTERED_CACHE_SIZE];
+  /* Rules filtered for a particular user-repository combination.
+   * May be NULL. */
+  authz_user_rules_t *filtered;
 
   /* The pool from which all the parsed authz data is allocated.
      This is the RESULT_POOL passed to svn_authz__tng_parse.



Mime
View raw message