FAQ
Edit report at http://pear.php.net/bugs/bug.php?id=18752&edit=1

ID: 18752
Updated by: beni@php.net
Reported By: xavier dot montagutelli at unilim dot fr
Summary: Performance problem retrieving search result + patch
-Status: Open
+Status: Verified
Type: Feature/Change Request
Package: Net_LDAP2
Operating System: GNU/Linux Debian
Package Version: 2.0.11
PHP Version: 5.3.0
-Assigned To:
+Assigned To: beni
Roadmap Versions:
New Comment:

-Status: Open
+Status: Verified
-Assigned To:
+Assigned To: beni



Previous Comments:
------------------------------------------------------------------------

[2011-08-23 16:46:47] montagut

Added #patch
bug:18752;patch:Search.php-shiftEntry.patch;revision:1314114407;.

------------------------------------------------------------------------

[2011-08-23 16:39:43] montagut

Description:
------------
There's a serious performance problem fetching results from a
search.

When doing a very simple search on a directory with around
50.000 entries, getting the results with the "shiftEntry"
methods takes a very long time, compared to using the native
PHP functions.

With Xdebug, I have identified the bottleneck. Each call to
"shiftEntry" calls "count", and this one calls
"ldap_count_entries". I suppose this function goes
through all the remaining results to give the count, so calling it
inefficient.

It can safely be removed, patch attached

Test script:
---------------
Test script (to run in command line mode) :

https://docs.google.com/leaf?id=0ByWMI5PuRIdwNDU5MDdmMGQtNTdiZC00MTYyLWI3YmQtMzIwZTU0YmQ1YzZj&hl=fr

Actual result:
--------------
1. Using PHP native LDAP functions
Number of entries : 22402
Search time : 2 seconds
Building list from search result : 0 seconds
2. Using Net_LDAP2 object
Number of entries : 22402
Search time : 2 seconds
Building list from search result : 15 seconds

------------------------------------------------------------------------

Search Discussions

  • Beni at Aug 24, 2011 at 5:44 am
    Edit report at http://pear.php.net/bugs/bug.php?id=18752&edit=1

    ID: 18752
    Updated by: beni@php.net
    Reported By: xavier dot montagutelli at unilim dot fr
    Summary: Performance problem retrieving search result + patch
    Status: Verified
    Type: Feature/Change Request
    Package: Net_LDAP2
    Operating System: GNU/Linux Debian
    Package Version: 2.0.11
    PHP Version: 5.3.0
    Assigned To: beni
    Roadmap Versions:
    New Comment:

    Confirmed this.
    However this would involve an API change.

    The better way is surely to cache the call to ldap_count_entries and
    return the count from that cache.

    I added a fix to count(). Please fetch the latest SVN version (revision
    xxx) and verify that your bug is solved now.

    Thanks for improving Net_LDAP2!


    Previous Comments:
    ------------------------------------------------------------------------

    [2011-08-24 07:24:40] beni

    -Status: Open
    +Status: Verified
    -Assigned To:
    +Assigned To: beni


    ------------------------------------------------------------------------

    [2011-08-23 16:46:47] montagut

    Added #patch
    bug:18752;patch:Search.php-shiftEntry.patch;revision:1314114407;.

    ------------------------------------------------------------------------

    [2011-08-23 16:39:43] montagut

    Description:
    ------------
    There's a serious performance problem fetching results from a
    search.

    When doing a very simple search on a directory with around
    50.000 entries, getting the results with the "shiftEntry"
    methods takes a very long time, compared to using the native
    PHP functions.

    With Xdebug, I have identified the bottleneck. Each call to
    "shiftEntry" calls "count", and this one calls
    "ldap_count_entries". I suppose this function goes
    through all the remaining results to give the count, so calling it
    inefficient.

    It can safely be removed, patch attached

    Test script:
    ---------------
    Test script (to run in command line mode) :

    https://docs.google.com/leaf?id=0ByWMI5PuRIdwNDU5MDdmMGQtNTdiZC00MTYyLWI3YmQtMzIwZTU0YmQ1YzZj&hl=fr

    Actual result:
    --------------
    1. Using PHP native LDAP functions
    Number of entries : 22402
    Search time : 2 seconds
    Building list from search result : 0 seconds
    2. Using Net_LDAP2 object
    Number of entries : 22402
    Search time : 2 seconds
    Building list from search result : 15 seconds

    ------------------------------------------------------------------------
  • Beni at Aug 24, 2011 at 5:45 am
    Edit report at http://pear.php.net/bugs/bug.php?id=18752&edit=1

    ID: 18752
    Updated by: beni@php.net
    Reported By: xavier dot montagutelli at unilim dot fr
    Summary: Performance problem retrieving search result + patch
    Status: Verified
    Type: Feature/Change Request
    Package: Net_LDAP2
    Operating System: GNU/Linux Debian
    Package Version: 2.0.11
    PHP Version: 5.3.0
    Assigned To: beni
    Roadmap Versions:
    New Comment:

    ok, it looks like the pear svn is down currently, so the fix is not in.
    i will add it as patch un til i can commit the change.


    Previous Comments:
    ------------------------------------------------------------------------

    [2011-08-24 07:45:26] beni

    Confirmed this.
    However this would involve an API change.

    The better way is surely to cache the call to ldap_count_entries and
    return the count from that cache.

    I added a fix to count(). Please fetch the latest SVN version (revision
    xxx) and verify that your bug is solved now.

    Thanks for improving Net_LDAP2!

    ------------------------------------------------------------------------

    [2011-08-24 07:24:40] beni

    -Status: Open
    +Status: Verified
    -Assigned To:
    +Assigned To: beni


    ------------------------------------------------------------------------

    [2011-08-23 16:46:47] montagut

    Added #patch
    bug:18752;patch:Search.php-shiftEntry.patch;revision:1314114407;.

    ------------------------------------------------------------------------

    [2011-08-23 16:39:43] montagut

    Description:
    ------------
    There's a serious performance problem fetching results from a
    search.

    When doing a very simple search on a directory with around
    50.000 entries, getting the results with the "shiftEntry"
    methods takes a very long time, compared to using the native
    PHP functions.

    With Xdebug, I have identified the bottleneck. Each call to
    "shiftEntry" calls "count", and this one calls
    "ldap_count_entries". I suppose this function goes
    through all the remaining results to give the count, so calling it
    inefficient.

    It can safely be removed, patch attached

    Test script:
    ---------------
    Test script (to run in command line mode) :

    https://docs.google.com/leaf?id=0ByWMI5PuRIdwNDU5MDdmMGQtNTdiZC00MTYyLWI3YmQtMzIwZTU0YmQ1YzZj&hl=fr

    Actual result:
    --------------
    1. Using PHP native LDAP functions
    Number of entries : 22402
    Search time : 2 seconds
    Building list from search result : 0 seconds
    2. Using Net_LDAP2 object
    Number of entries : 22402
    Search time : 2 seconds
    Building list from search result : 15 seconds

    ------------------------------------------------------------------------
  • Beni at Aug 24, 2011 at 6:41 am
    Edit report at http://pear.php.net/bugs/bug.php?id=18752&edit=1

    ID: 18752
    Updated by: beni@php.net
    Reported By: xavier dot montagutelli at unilim dot fr
    Summary: Performance problem retrieving search result + patch
    Status: Verified
    Type: Feature/Change Request
    Package: Net_LDAP2
    Operating System: GNU/Linux Debian
    Package Version: 2.0.11
    PHP Version: 5.3.0
    Assigned To: beni
    Roadmap Versions:
    New Comment:

    Its in SVN now. Please test.


    Previous Comments:
    ------------------------------------------------------------------------

    [2011-08-24 07:48:29] beni

    Added #patch
    bug:18752;patch:Search.php_addCountCache.patch;revision:1314168509;.

    ------------------------------------------------------------------------

    [2011-08-24 07:46:07] beni

    ok, it looks like the pear svn is down currently, so the fix is not in.
    i will add it as patch un til i can commit the change.

    ------------------------------------------------------------------------

    [2011-08-24 07:45:26] beni

    Confirmed this.
    However this would involve an API change.

    The better way is surely to cache the call to ldap_count_entries and
    return the count from that cache.

    I added a fix to count(). Please fetch the latest SVN version (revision
    xxx) and verify that your bug is solved now.

    Thanks for improving Net_LDAP2!

    ------------------------------------------------------------------------

    [2011-08-24 07:24:40] beni

    -Status: Open
    +Status: Verified
    -Assigned To:
    +Assigned To: beni


    ------------------------------------------------------------------------

    [2011-08-23 16:46:47] montagut

    Added #patch
    bug:18752;patch:Search.php-shiftEntry.patch;revision:1314114407;.

    ------------------------------------------------------------------------

    The remainder of the comments for this report are too long. To view
    the rest of the comments, please view the bug report online at
    http://pear.php.net/bugs/bug.php?id=18752
  • Xavier Montagutelli at Aug 24, 2011 at 12:01 pm
    Edit report at http://pear.php.net/bugs/bug.php?id=18752&edit=1

    ID: 18752
    Comment by: xavier.montagutelli@unilim.fr
    Reported By: xavier dot montagutelli at unilim dot fr
    Summary: Performance problem retrieving search result + patch
    Status: Verified
    Type: Feature/Change Request
    Package: Net_LDAP2
    Operating System: GNU/Linux Debian
    Package Version: 2.0.11
    PHP Version: 5.3.0
    Assigned To: beni
    Roadmap Versions:
    New Comment:

    Your patch is not correct, it misses the underscore in the
    "count_entries" variable.

    Once corrected with the patch missingUnderscoreForCountCache, it works
    better. Here are the numbers :

    # php liste-net-ldap2.php

    1. Using PHP native LDAP functions
    Number of entries : 22407
    Search time : 2 seconds
    Building list from search result : 0 seconds
    2. Using Net_LDAP2 object
    Number of entries : 22407
    Search time : 2 seconds
    Building list from search result : 8 seconds

    Net_LDAP2 is always much slower than the native LDAP functions, but we
    have reduced the difference (from 15 s to 8 s).

    But, why do you want to maintain the call to the "count" method at the
    beginning of "shiftEntry" ? My first patch could be improved by testing
    the result of ldap_first_entry to get rid of this call. If there are no
    result, it returns false. So the call to "count" is useless.

    Both patches could be inserted, as they serve different purposes in
    fact.


    Previous Comments:
    ------------------------------------------------------------------------

    [2011-08-24 13:51:19] montagut

    Added #patch
    bug:18752;patch:missingUnderscoreForCountCache;revision:1314190279;.

    ------------------------------------------------------------------------

    [2011-08-24 08:42:12] beni

    Its in SVN now. Please test.

    ------------------------------------------------------------------------

    [2011-08-24 07:48:29] beni

    Added #patch
    bug:18752;patch:Search.php_addCountCache.patch;revision:1314168509;.

    ------------------------------------------------------------------------

    [2011-08-24 07:46:07] beni

    ok, it looks like the pear svn is down currently, so the fix is not in.
    i will add it as patch un til i can commit the change.

    ------------------------------------------------------------------------

    [2011-08-24 07:45:26] beni

    Confirmed this.
    However this would involve an API change.

    The better way is surely to cache the call to ldap_count_entries and
    return the count from that cache.

    I added a fix to count(). Please fetch the latest SVN version (revision
    xxx) and verify that your bug is solved now.

    Thanks for improving Net_LDAP2!

    ------------------------------------------------------------------------

    The remainder of the comments for this report are too long. To view
    the rest of the comments, please view the bug report online at
    http://pear.php.net/bugs/bug.php?id=18752
  • Beni at Aug 24, 2011 at 12:13 pm
    Edit report at http://pear.php.net/bugs/bug.php?id=18752&edit=1

    ID: 18752
    Updated by: beni@php.net
    Reported By: xavier dot montagutelli at unilim dot fr
    Summary: Performance problem retrieving search result + patch
    -Status: Verified
    +Status: Closed
    Type: Feature/Change Request
    Package: Net_LDAP2
    Operating System: GNU/Linux Debian
    Package Version: 2.0.11
    PHP Version: 5.3.0
    Assigned To: beni
    Roadmap Versions:
    New Comment:

    -Status: Verified
    +Status: Closed
    This bug has been fixed in SVN.

    If this was a documentation problem, the fix will appear on pear.php.net
    by the end of next Sunday (CET).

    If this was a problem with the pear.php.net website, the change should
    be live shortly.

    Otherwise, the fix will appear in the package's next release.

    Thank you for the report and for helping us make PEAR better.

    Hello again, thanks for your help!

    I implemented both patches now, so the code should run faster.


    Previous Comments:
    ------------------------------------------------------------------------

    [2011-08-24 14:01:49] montagut

    Your patch is not correct, it misses the underscore in the
    "count_entries" variable.

    Once corrected with the patch missingUnderscoreForCountCache, it works
    better. Here are the numbers :

    # php liste-net-ldap2.php

    1. Using PHP native LDAP functions
    Number of entries : 22407
    Search time : 2 seconds
    Building list from search result : 0 seconds
    2. Using Net_LDAP2 object
    Number of entries : 22407
    Search time : 2 seconds
    Building list from search result : 8 seconds

    Net_LDAP2 is always much slower than the native LDAP functions, but we
    have reduced the difference (from 15 s to 8 s).

    But, why do you want to maintain the call to the "count" method at the
    beginning of "shiftEntry" ? My first patch could be improved by testing
    the result of ldap_first_entry to get rid of this call. If there are no
    result, it returns false. So the call to "count" is useless.

    Both patches could be inserted, as they serve different purposes in
    fact.

    ------------------------------------------------------------------------

    [2011-08-24 13:51:19] montagut

    Added #patch
    bug:18752;patch:missingUnderscoreForCountCache;revision:1314190279;.

    ------------------------------------------------------------------------

    [2011-08-24 08:42:12] beni

    Its in SVN now. Please test.

    ------------------------------------------------------------------------

    [2011-08-24 07:48:29] beni

    Added #patch
    bug:18752;patch:Search.php_addCountCache.patch;revision:1314168509;.

    ------------------------------------------------------------------------

    [2011-08-24 07:46:07] beni

    ok, it looks like the pear svn is down currently, so the fix is not in.
    i will add it as patch un til i can commit the change.

    ------------------------------------------------------------------------

    The remainder of the comments for this report are too long. To view
    the rest of the comments, please view the bug report online at
    http://pear.php.net/bugs/bug.php?id=18752

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
categoriesphp
postedAug 24, '11 at 5:24a
activeAug 24, '11 at 12:13p
posts6
users2
websitepear.php.net

2 users in discussion

Beni: 5 posts Xavier Montagutelli: 1 post

People

Translate

site design / logo © 2022 Grokbase