#49750 Ticket 49732 - Optimize resource limit checking for rootdn issued searches
Closed 3 years ago by spichugi. Opened 5 years ago by mreynolds.
mreynolds/389-ds-base ticket49732  into  master

@@ -52,37 +52,50 @@ 

      Slapi_Connection *conn = NULL;

      int limit;

      Slapi_Operation *op;

+     int isroot = 0;

  

+     slapi_pblock_get(pb, SLAPI_REQUESTOR_ISROOT, &isroot);

      slapi_pblock_get(pb, SLAPI_CONNECTION, &conn);

      slapi_pblock_get(pb, SLAPI_OPERATION, &op);

  

-     if (slapi_reslimit_get_integer_limit(conn,

-                                          li->li_reslimit_lookthrough_handle, &limit) != SLAPI_RESLIMIT_STATUS_SUCCESS) {

-         /*

-          * no limit associated with binder/connection or some other error

-          * occurred.  use the default.

-           */

-         int isroot = 0;

- 

-         slapi_pblock_get(pb, SLAPI_REQUESTOR_ISROOT, &isroot);

-         if (isroot) {

-             limit = -1;

+     if (isroot) {

+         limit = -1;

+     } else {

+         if (op_is_pagedresults(op)) {

+             if (slapi_reslimit_get_integer_limit(conn,

+                 li->li_reslimit_pagedlookthrough_handle, &limit) != SLAPI_RESLIMIT_STATUS_SUCCESS)

+             {

+                 PR_Lock(li->li_config_mutex);

+                 if (li->li_pagedlookthroughlimit) {

+                     limit = li->li_pagedlookthroughlimit;

+                 } else {

+                     /* No paged search lookthroughlimit, so use DB lookthroughlimit.

+                      * First check if we have a "resource limit" that applies to this

+                      * connection, otherwise use the global DB lookthroughlimit

+                      */

+                     if (slapi_reslimit_get_integer_limit(conn,

+                             li->li_reslimit_lookthrough_handle, &limit) != SLAPI_RESLIMIT_STATUS_SUCCESS)

+                     {

+                         /* Default to global DB lookthroughlimit */

+                         limit = li->li_lookthroughlimit;

+                     }

+                 }

+                 /* else set above */

+                 PR_Unlock(li->li_config_mutex);

+             }

          } else {

-             PR_Lock(li->li_config_mutex);

-             limit = li->li_lookthroughlimit;

-             PR_Unlock(li->li_config_mutex);

-         }

-     }

- 

-     if (op_is_pagedresults(op)) {

-         if (slapi_reslimit_get_integer_limit(conn,

-                                              li->li_reslimit_pagedlookthrough_handle, &limit) != SLAPI_RESLIMIT_STATUS_SUCCESS) {

-             PR_Lock(li->li_config_mutex);

-             if (li->li_pagedlookthroughlimit) {

-                 limit = li->li_pagedlookthroughlimit;

+             /* Regular search */

+             if (slapi_reslimit_get_integer_limit(conn,

+                 li->li_reslimit_lookthrough_handle, &limit) != SLAPI_RESLIMIT_STATUS_SUCCESS)

+             {

+                 /*

+                  * no limit associated with binder/connection or some other error

+                  * occurred.  use the default.

+                  */

+                 PR_Lock(li->li_config_mutex);

+                 limit = li->li_lookthroughlimit;

+                 PR_Unlock(li->li_config_mutex);

              }

-             /* else set above */

-             PR_Unlock(li->li_config_mutex);

          }

      }

      return (limit);

file modified
+26 -26
@@ -1483,17 +1483,16 @@ 

      /*

       * Compute the time limit.

       */

-     if (slapi_reslimit_get_integer_limit(pb_conn,

-                                          timelimit_reslimit_handle, &max_timelimit) != SLAPI_RESLIMIT_STATUS_SUCCESS) {

+     if (isroot) {

+         max_timelimit = -1; /* no limit */

+     } else  if (slapi_reslimit_get_integer_limit(pb_conn,

+         timelimit_reslimit_handle, &max_timelimit) != SLAPI_RESLIMIT_STATUS_SUCCESS)

+     {

          /*

           * no limit associated with binder/connection or some other error

           * occurred.  use the default maximum.

-           */

-         if (isroot) {

-             max_timelimit = -1; /* no limit */

-         } else {

-             max_timelimit = be->be_timelimit;

-         }

+          */

+         max_timelimit = be->be_timelimit;

      }

  

      if (requested_timelimit) {
@@ -1519,30 +1518,31 @@ 

      /*

       * Compute the size limit.

       */

-     if (slapi_reslimit_get_integer_limit(pb_conn,

-                                          sizelimit_reslimit_handle, &max_sizelimit) != SLAPI_RESLIMIT_STATUS_SUCCESS) {

-         /*

-          * no limit associated with binder/connection or some other error

-          * occurred.  use the default maximum.

-           */

-         if (isroot) {

-             max_sizelimit = -1; /* no limit */

-         } else {

-             max_sizelimit = be->be_sizelimit;

-         }

-     }

- 

-     if (op_is_pagedresults(op)) {

+     if (isroot) {

+         max_sizelimit = -1; /* no limit */

+     } else {

          if (slapi_reslimit_get_integer_limit(pb_conn,

-                                              pagedsizelimit_reslimit_handle, &max_sizelimit) != SLAPI_RESLIMIT_STATUS_SUCCESS) {

+             sizelimit_reslimit_handle, &max_sizelimit) != SLAPI_RESLIMIT_STATUS_SUCCESS)

+         {

              /*

               * no limit associated with binder/connection or some other error

               * occurred.  use the default maximum.

               */

-             if (be->be_pagedsizelimit) {

-                 max_sizelimit = be->be_pagedsizelimit;

+             max_sizelimit = be->be_sizelimit;

+         }

+ 

+         if (op_is_pagedresults(op)) {

+             if (slapi_reslimit_get_integer_limit(pb_conn,

+                 pagedsizelimit_reslimit_handle, &max_sizelimit) != SLAPI_RESLIMIT_STATUS_SUCCESS) {

+                 /*

+                  * no limit associated with binder/connection or some other error

+                  * occurred.  use the default maximum.

+                  */

+                 if (be->be_pagedsizelimit) {

+                     max_sizelimit = be->be_pagedsizelimit;

+                 }

+                 /* else was already set above */

              }

-             /* else was already set above */

          }

      }

  

Description: When performing a search as the Directory Manager resource limits
should not apply. So there is no need to "get" the limits if its
a Directory Manager initiated search. I'm seeing around 2% performance
increase when we skip getting the resource limits.

https://pagure.io/389-ds-base/issue/49732

Reviewed by: ?

Signed-off-by: Mark Reynolds mreynolds@redhat.com

The patch looks good to me. Ack

rebased onto 67efef0

5 years ago

Pull-Request has been merged by mreynolds

5 years ago

389-ds-base is moving from Pagure to Github. This means that new issues and pull requests
will be accepted only in 389-ds-base's github repository.

This pull request has been cloned to Github as issue and is available here:
- https://github.com/389ds/389-ds-base/issues/2809

If you want to continue to work on the PR, please navigate to the github issue,
download the patch from the attachments and file a new pull request.

Thank you for understanding. We apologize for all inconvenience.

Pull-Request has been closed by spichugi

3 years ago