http://bugzilla.mozilla.org/show_bug.cgi?id=231623
What are the chances of having this patch (or some effective variation) included? Any discussion or suggestions on how I may be handling this better would be welcome. Thanks very much. -Luke
[Here is the text from the bugzilla post:]
When I query an ldap server w/ the java sdk for a group that has 17000 users in it, it takes 35 seconds to get the data back. The data comes to my PC instantly (i.e., not a network or server issue), but the API takes that long to do a "next()" to process it. I debugged into the code and that the performance bottleneck is in com.netscape.jndi.ldap.AttributesImpl.java's
ldapAttrToJndiAttr() method. If I change this line:
BasicAttribute jndiAttr = new BasicAttribute(attr.getName());
...to this...
BasicAttribute jndiAttr = new BasicAttribute(attr.getName(),true); // added
"true", 1/2004 lacall ([EMAIL PROTECTED]; Luke Call)
...then I no longer see the problem (goes from 35 seconds down to 40 ms).
However, I don't know all the implications for other uses of the API, of forcing that "true" parameter, which means "unsorted". It has worked w/ my minimal testing so far. Maybe a different change would be better (if I knew the api structure better and why it does things a certain way), for example, to allow passing a parameter from a higher-level API w/in this library, that would not be a default and would then cause this one to be "true", as in my change.
Reproducible: Always
Steps to Reproduce: Here is sample code to reproduce the issue. The slow part of this code is building up the test data, 17000 elements in a list. If you put this in a "main()" and step into the SDK calls you can see that the SDK is checking the entire list for duplicates, every time you do an add(), unless you change it as I indicated above, passing "true" (for unsorted).
javax.naming.directory.BasicAttribute jndiAttr = new
javax.naming.directory.BasicAttribute("some_big_group",true); //attr.getName()
//build the test data set--takes a bit but needed to demo the other
String tokens="";
System.out.println("time 1:"+System.getCurrentTimeMillis());
for (int i=0;i<17000;i++) {
tokens+=" "+i;
}
StringTokenizer st = new StringTokenizer(tokens);
System.out.println("time 2:"+System.getCurrentTimeMillis());
while (st.hasMoreTokens()) {
jndiAttr.add(st.nextToken()); // <-- THIS IS THE SLOW LINE
}
System.out.println("time 3:"+System.getCurrentTimeMillis());
Actual Results: The last loop takes 35 seconds on my PC to process, for the reasons described. Is same on Solaris and XP (of course :).
Expected Results: see notes above
I am interested in any discussion on this, especially if I should learn something or do anything differently. Thanks!!
_______________________________________________ mozilla-directory mailing list [EMAIL PROTECTED] http://mail.mozilla.org/listinfo/mozilla-directory
