From: Mark W. <mew...@un...> - 2000-07-27 03:13:40
|
Well, duhhhhh :) (and what's one of the greatest Perl phrases, "You might write faster code in C, but you'll write code faster in Perl"). Net::LDAP is written in pure Perl, thus it will be slower than anything written in C. Now we know where the bulk of the speed problems are and they are in Convert::ASN1 because everything in LDAP must be encoded/decoded from BER before transport. At some future point, Graham (or someone else??) may write an optional C backend for ASN1 (e.g. it would compile in C if you had a C compiler, otherwise it would remain pure Perl). But that will come after Net::LDAP is more complete. Now there are some things you can do to improve performance and efficiency, namely callbacks. They'll reduce the amount of memory you consume & will enable you to process results as soon as Net::LDAP gets them, instead of having to wait until the end. Speed is also in the eye of the beholder and CPU. For example, if most your application delay is going to be in network latency regardless of language, then write in C becuase it won't really matter. If the program is run in batch mode, where perhaps the Perl program takes an extra 15 minutes to run, but you can write it in less than 20 minutes, as opposed to an hour or more in C,. is that worth it? As for the other Perl modules, well, we're really the only one left :). PerLDAP hasn't seen a release in over a year and I don't anticipate one anytime soon. Plus the user community has dried up, heck the guy who wrote the original code that PerLDAP is based on, uses us because it's so much easier & functional (the next version will have real support for controls & DSML & SSL!). And we test against just about every LDAP server you'll ever encounter. Thus, the performance isn't going to dramatically improve anytime soon (unless you go from a 200 MHZ to a 800MHZ CPU ;), but there are things that can make your program to appear to run faster. Or you are free to work with us to try to add the C backend to the ASN1 module. I'm also willing to help you optimize your application (for example if it's CGI based, use mod_perl instead of traditional CGI, keep a static connection open to the server). Net::LDAP may not be a total speed deamon, but I've been using it for over 2 years and it's portability has come in more handy than any speed concerns. Mark Luke Kanies wrote: > Hi all. I have some questions about perceived speed of Net::LDAP. I > ran some quick comparisons between it and the command line, and am > willing to do more if anyone wants more info. > > My problem is that Net::LDAP appears to be about an order of magnitude > slower for search operations than the corresponding command line > function. > > For instance, I have an ldap database with 1768 ou's in it, and I > performed three different types of searches on it using both the command > line and Net::LDAP. First I just dumped all of the entries to the > screen; then I built a hash of all of the entries, of the form > $hash{$dn}->{$attr} = $value. Finally, I did another search and just > counted the entries. > > For the command line functions, to dump to screen I just used system(), > to build the hash, I used open() and then match and split, and to count > I used open() and counted blank lines. > > For Net::LDAP, to dump I did the search and cycled through the entries > with $entry->dump, to build the hash, I cycled through and used: > $dn = $entry->dn; > foreach $attr ($entry->attributes) > { > $hash{$dn}->{$attr} = $entry->get($attr); > } > > and for counting, I just did a $count++ for each entry. > > For each Net::LDAP search I opened and closed the connection for each > time test. > > Here are the numbers that I found: > > Net: dump 21 > Net: hash 14 > Net: count 16 > CLI: dump 2 > CLI: hash 1 > CLI: count 1 > > As you can see, Net::LDAP performed pretty abysmally. My question is, > does everyone else see this too, and is it going to be addressed? If > it's not going to be fixed, is Net::LDAPapi or Mozilla::LDAP any > better? I really can't afford 20 seconds for all of my searches, so if > Net::LDAP is going to take that long, I can't use it. And I want to > avoid the command line if possible, since I don't like the idea of > running long searches using the user's password on the command line. > > If anyone is interested, I can send my code, or I can run more tests. I > really would like to use Net::LDAP, since it is tons easier to use the > Net::LDAPapi, but I can't if it is going to be this slow. > > Thanks, and please email me if you have any questions about my results. > > -- > Luke A. Kanies | "Most people are born and years later die without > System Engineer | really having lived at all. They play it safe and > 615/778-7268 | tiptoe through life with no aspiration other than to > pgr 800/415-1972| arrive at death safely."-Tony Campolo, "Carpe Diem" |