On 02/09/2015 06:01 PM, pankaj.tolani wrote:
> On Mon, Feb 9, 2015 at 11:12 PM, Neil A. Wilson <nei...@un...>
> wrote:
>
>> On 02/09/2015 04:48 PM, pankaj.tolani wrote:
>>
>>> With ConcurrentSkipListMap, the performance halved.
>>>
>>
>> Performance halved over not using any synchronization at all, or over the
>> fully-synchronized implementation?
>>
>> For TreeMap -> ConcurrentSkipListMap
>
>>
>> If the modify operations are going to be on disjoint entries in the
>>> entryMap, and sequential within a thread, isnt TreeMap still OK?
>>>
>>
>> No. It is not safe for multiple threads to interact with a non-concurrent
>> map without synchronization if there is any chance that the content of the
>> map may change (by adding new entries, or by removing or replacing existing
>> entries). This will create the possibility for a race condition that could
>> result in a deadlock or a ConcurrentModificationException. It may be
>> rare that you actually encounter it, but it's a definite possibility and
>> should not be ignored.
>>
> I do not add/remove entries. Wonder why replacing values of existing
> entries would be unsafe unless my execution paths need using the iterator.
I am not intimately familiar with the TreeMap implementation, but the
general rule is that unless a map is explicitly stated to be threadsafe,
you should assume that it is not safe to alter it in any way while other
threads might access it.
Further, I should also reiterate that there are other parts of the
in-memory directory server code that depend on the thread safety
umbrella that the aggressive synchronization provides. Indexes are
definitely one such component, but there may be others.
If you need the highest possible performance and scalability, and can
accomplish that by returning canned or generated responses instead of
storing data, then the custom request handler route is the way to go.
>
>>
>> Also, I just realized that the ConcurrentSkipListMap suggestion isn't safe
>> if you're using indexes because the "synchronized (entryMap)" block ensures
>> that accesses to indexes (as well as other features like change logging)
>> are safe.
>>
> I stopped using indexes, as I got a big jump by using a BASE scope search
> instead of SUB scope search.
>
>>
>> If you expect to have a lot more reads than writes, then you could
>> probably convert the existing synchronization to be based on a read-write
>> lock, where read operations like bind, compare, and search acquire the read
>> lock (which will allow them to operate concurrently) and other operations
>> like add, delete, modify, and modify DN have to get the write lock (which
>> would ensure that operation is the only one in progress).
>>
> Thats a good suggestion. But we have nearly same number of reads/writes.
>
>>
>> Beyond that, trying to turn the in-memory directory server into a high
>> performance, highly-concurrent directory server that is safe under all
>> conditions would be a substantial undertaking. It wasn't designed with
>> those goals in mind. However, if you only have a very specific subset of
>> operations to support, and you are more concerned about testing the
>> performance of your application, then you may be able to create a custom
>> LDAPListenerRequestHandler implementation that satisfies your application
>> but doesn't actually need to store any data. For example, the
>> CannedResponseRequestHandler will return a predetermined response to any
>> request and that will be very fast. I'm not saying that the
>> CannedResponseRequestHandler is suitable for what you need, but you may be
>> able to create something similar that does suit your needs without any
>> concerns about safety, and also without any concerns about the
>> maintainability of your code (because if you make changes to the LDAP SDK
>> code itself, then you'll have to re-apply those changes if you want to
>> switch to a newer version of the LDAP SDK).
>>
>> Yes. thats the plan. Simulated response.
>
> Again, many thanks for your help.
>
>>
>>
>>
>>>
>>> On Mon, Feb 9, 2015 at 10:35 PM, Neil A. Wilson <
>>> nei...@un...>
>>> wrote:
>>>
>>> On 02/09/2015 04:21 PM, pankaj.tolani wrote:
>>>>
>>>> Many thanks Neil, for your detailed response.
>>>>>
>>>>> So, our idea is to internal factory acceptance performance test an
>>>>> application.
>>>>>
>>>>> Now, we mainly have just search and modify operations. No adds and
>>>>> deletes.
>>>>> Also multiple threads are going to operate on disjoint set of entries.
>>>>> With
>>>>> this in mind, I was hoping we could remove the synchronized(entryMap) {}
>>>>> on
>>>>> all the operations. Does this sound OK?
>>>>>
>>>>>
>>>> This would not be safe if you're performing modify operations, because
>>>> modify operations change the contents of the map.
>>>>
>>>> You might be able to get away with doing that if you changed entryMap
>>>> from
>>>> a TreeMap to a ConcurrentSkipListMap. I haven't looked at the code
>>>> closely
>>>> enough to know if that will eliminate the worst possibilities of
>>>> eliminating synchronization (in particular, deadlocks and concurrent
>>>> modification exceptions), but I know that it won't guarantee correct
>>>> behavior in all circumstances (e.g., if multiple threads try to alter the
>>>> same entry at the same time).
>>>>
>>>>
>>>>
>>>>
>>>> Also, I have been able to convert my SUB scope query to a BASE query.
>>>>>
>>>>> With this, I am getting a decent performance for 10000 subscribers, 2-3
>>>>> msec for one search and one update operation.
>>>>>
>>>>> On Mon, Feb 9, 2015 at 6:08 PM, Neil A. Wilson <
>>>>> nei...@un...
>>>>>
>>>>>>
>>>>>> wrote:
>>>>>
>>>>> On 02/09/2015 11:47 AM, pankaj.tolani wrote:
>>>>>
>>>>>>
>>>>>> BTW with search/update, I meant 1 search + 1 update. Just to be
>>>>>> clear.
>>>>>>
>>>>>>>
>>>>>>> And I want to avoid the linear loop in
>>>>>>> InMemoryRequestHandler.processSearchRequest which reads
>>>>>>>
>>>>>>>
>>>>>>> First, I should point out that the in-memory directory server isn't
>>>>>> meant
>>>>>> to be fast, nor should it ever under any circumstances be used in any
>>>>>> circumstance that requires a production-quality directory server. The
>>>>>> in-memory directory server is meant to be a stable, correct,
>>>>>> standards-compliant directory server that you can easily use for
>>>>>> development and testing purposes. There are many essential features
>>>>>> for
>>>>>> production deployments that there are no plans to provide, like access
>>>>>> control, replication/high availability, and data durability.
>>>>>>
>>>>>> I'm not really sure what value there is in conducting
>>>>>> load/performance/scalability tests against the server because it is not
>>>>>> intended to be fast or scalable. It makes use of very heavy locking as
>>>>>> an
>>>>>> easy way to ensure correct behavior by ensuring that the server may
>>>>>> only
>>>>>> ever attempt to process one operation at a time. There are much better
>>>>>> ways to provide concurrency, but the approach it currently uses is both
>>>>>> very simple to implement and a very easy way to guarantee that there is
>>>>>> no
>>>>>> concern about conflicts between operations.
>>>>>>
>>>>>> However, depending on the type of search that you are performing, it
>>>>>> might
>>>>>> be possible to define one or more indexes that would dramatically
>>>>>> improve
>>>>>> performance and eliminate the need to iterate across all of the
>>>>>> entries.
>>>>>> Since you haven't indicated what kinds of searches you are performing,
>>>>>> it's
>>>>>> not possible to determine whether indexes can help. However, if your
>>>>>> searches are simple filters like "(uid=user.1234)", then you could
>>>>>> define
>>>>>> an index for the uid attribute and get much better performance.
>>>>>>
>>>>>> At present, the in-memory directory server only provides support for
>>>>>> equality indexes. This can help improve the performance of searches
>>>>>> with
>>>>>> filters that look like "(indexedAttribute=value)". Equality indexes
>>>>>> can
>>>>>> also be used for AND filters that contain at least one equality
>>>>>> component
>>>>>> that targets the indexed attribute, like "(&(indexedAttribute=value)(
>>>>>> someOtherAttribute=someOtherValue))", and for OR filters in which all
>>>>>> of
>>>>>> the components are equality components targeting the indexed attribute.
>>>>>>
>>>>>> To configure the in-memory directory server with one or more equality
>>>>>> indexes, use the InMemoryDirectoryServerConfig.
>>>>>> setEqualityIndexAttributes
>>>>>> method and pass in the names of the attributes you want to index.
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> for (final Map.Entry<DN,ReadOnlyEntry> me : entryMap.entrySet())
>>>>>>
>>>>>>> {
>>>>>>> final DN dn = me.getKey();
>>>>>>> final Entry entry = me.getValue();
>>>>>>> try
>>>>>>> {
>>>>>>> if (dn.matchesBaseAndScope(baseDN, scope) &&
>>>>>>> filter.matchesEntry(entry, schema))
>>>>>>> {
>>>>>>> processSearchEntry(entry, includeSubEntries,
>>>>>>> includeChangeLog,
>>>>>>> hasManageDsaIT, fullEntryList, referenceList);
>>>>>>> }
>>>>>>> }
>>>>>>> catch (final Exception e)
>>>>>>> {
>>>>>>> Debug.debugException(e);
>>>>>>> }
>>>>>>> }
>>>>>>>
>>>>>>> On Mon, Feb 9, 2015 at 5:43 PM, pankaj.tolani <
>>>>>>> pan...@gm...>
>>>>>>> wrote:
>>>>>>>
>>>>>>> Thanks Neil. Just before you replied, a colleague helped me with
>>>>>>> it.
>>>>>>>
>>>>>>>
>>>>>>>> I am doing a search/update load test with 4000 vs 40000 entires
>>>>>>>> against
>>>>>>>> InMemoryServer. Doing a load of search/update on 4000 entries takes
>>>>>>>> 40
>>>>>>>> odd
>>>>>>>> seconds, whereas 350 odd seconds with 40000 entries. Looking at the
>>>>>>>> profiler output, it seems most of the time is spent in
>>>>>>>> InMemoryRequestHandler.processSearchRequest - calls to
>>>>>>>> DN.matchesBaseAndScope. Looking at the code around this, seems like
>>>>>>>> filter
>>>>>>>> indexes might help. But I dont know what they mean and do they apply
>>>>>>>> to
>>>>>>>> InMemoryDirectoryServer.
>>>>>>>>
>>>>>>>> final Set<DN> candidateDNs = indexSearch(filter);
>>>>>>>> if (candidateDNs == null)
>>>>>>>> {
>>>>>>>> // my execution lands up here
>>>>>>>> }
>>>>>>>> else {
>>>>>>>> // how do I come here
>>>>>>>> }
>>>>>>>>
>>>>>>>> My seach is Scope SUB with a search filter which is an OR of two
>>>>>>>> object
>>>>>>>> classses.
>>>>>>>>
>>>>>>>> On Mon, Feb 9, 2015 at 4:59 PM, Neil A. Wilson <
>>>>>>>> nei...@un...>
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>> On 02/09/2015 04:36 AM, pankaj.tolani wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>>> Hello,
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>> I have checked out the ldap-sdk-code from svn://
>>>>>>>>>> svn.code.sf.net/p/ldap-sdk/code/trunk, but it does not compile.
>>>>>>>>>>
>>>>>>>>>> I get lots of errors, examples being
>>>>>>>>>>
>>>>>>>>>> ASN1Boolean.java - import static com.unboundid.asn1.
>>>>>>>>>> ASN1Messages.*;
>>>>>>>>>>
>>>>>>>>>> InMemoryDirectoryServer.java - import static
>>>>>>>>>> com.unboundid.ldap.listener.ListenerMessages.*;
>>>>>>>>>>
>>>>>>>>>> What steps am I missing?
>>>>>>>>>>
>>>>>>>>>> regards,
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> How are you trying to compile it? It sounds as if you might
>>>>>>>>>> just be
>>>>>>>>>>
>>>>>>>>> doing a javac of everything in the src directory, and that's not
>>>>>>>>> good
>>>>>>>>> enough because the build process needs to do other work first (e.g.,
>>>>>>>>> generate source code containing build properties like product name,
>>>>>>>>> version, build date, etc., and also to generate source code from the
>>>>>>>>> messages properties files to guarantee that the code can't try to
>>>>>>>>> use
>>>>>>>>> any
>>>>>>>>> messages that aren't defined).
>>>>>>>>>
>>>>>>>>> The easiest way to build the LDAP SDK is to just run the build-se.sh
>>>>>>>>> shell script on UNIX-based systems, or the build-se.bat batch file
>>>>>>>>> on
>>>>>>>>> Windows. Alternately, if you've got Apache ant installed, then you
>>>>>>>>> can
>>>>>>>>> run
>>>>>>>>> "ant -buildfile build-se.xml".
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Neil
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> ------------------------------------------------------------
>>>>>>>>> ------------------
>>>>>>>>> Dive into the World of Parallel Programming. The Go Parallel
>>>>>>>>> Website,
>>>>>>>>> sponsored by Intel and developed in partnership with Slashdot Media,
>>>>>>>>> is
>>>>>>>>> your
>>>>>>>>> hub for all things parallel software development, from weekly
>>>>>>>>> thought
>>>>>>>>> leadership blogs to news, videos, case studies, tutorials and more.
>>>>>>>>> Take a
>>>>>>>>> look and join the conversation now. http://goparallel.sourceforge.
>>>>>>>>> net/
>>>>>>>>> _______________________________________________
>>>>>>>>> ldap-sdk-discuss mailing list
>>>>>>>>> lda...@li...
>>>>>>>>> https://lists.sourceforge.net/lists/listinfo/ldap-sdk-discuss
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> --
>>>>>>>> पंकज एम तोलानी
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> ------------------------------------------------------------
>>>>>>> ------------------
>>>>>>> Dive into the World of Parallel Programming. The Go Parallel Website,
>>>>>>> sponsored by Intel and developed in partnership with Slashdot Media,
>>>>>>> is
>>>>>>> your
>>>>>>> hub for all things parallel software development, from weekly thought
>>>>>>> leadership blogs to news, videos, case studies, tutorials and more.
>>>>>>> Take a
>>>>>>> look and join the conversation now. http://goparallel.sourceforge.
>>>>>>> net/
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> ldap-sdk-discuss mailing list
>>>>>>> lda...@li...
>>>>>>> https://lists.sourceforge.net/lists/listinfo/ldap-sdk-discuss
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>> ------------------------------------------------------------
>>>>>> ------------------
>>>>>> Dive into the World of Parallel Programming. The Go Parallel Website,
>>>>>> sponsored by Intel and developed in partnership with Slashdot Media, is
>>>>>> your
>>>>>> hub for all things parallel software development, from weekly thought
>>>>>> leadership blogs to news, videos, case studies, tutorials and more.
>>>>>> Take
>>>>>> a
>>>>>> look and join the conversation now. http://goparallel.sourceforge.net/
>>>>>> _______________________________________________
>>>>>> ldap-sdk-discuss mailing list
>>>>>> lda...@li...
>>>>>> https://lists.sourceforge.net/lists/listinfo/ldap-sdk-discuss
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> ------------------------------------------------------------
>>>>> ------------------
>>>>> Dive into the World of Parallel Programming. The Go Parallel Website,
>>>>> sponsored by Intel and developed in partnership with Slashdot Media, is
>>>>> your
>>>>> hub for all things parallel software development, from weekly thought
>>>>> leadership blogs to news, videos, case studies, tutorials and more.
>>>>> Take a
>>>>> look and join the conversation now. http://goparallel.sourceforge.net/
>>>>>
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> ldap-sdk-discuss mailing list
>>>>> lda...@li...
>>>>> https://lists.sourceforge.net/lists/listinfo/ldap-sdk-discuss
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>> ------------------------------------------------------------
>>>> ------------------
>>>> Dive into the World of Parallel Programming. The Go Parallel Website,
>>>> sponsored by Intel and developed in partnership with Slashdot Media, is
>>>> your
>>>> hub for all things parallel software development, from weekly thought
>>>> leadership blogs to news, videos, case studies, tutorials and more. Take
>>>> a
>>>> look and join the conversation now. http://goparallel.sourceforge.net/
>>>> _______________________________________________
>>>> ldap-sdk-discuss mailing list
>>>> lda...@li...
>>>> https://lists.sourceforge.net/lists/listinfo/ldap-sdk-discuss
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>> ------------------------------------------------------------
>>> ------------------
>>> Dive into the World of Parallel Programming. The Go Parallel Website,
>>> sponsored by Intel and developed in partnership with Slashdot Media, is
>>> your
>>> hub for all things parallel software development, from weekly thought
>>> leadership blogs to news, videos, case studies, tutorials and more. Take a
>>> look and join the conversation now. http://goparallel.sourceforge.net/
>>>
>>>
>>>
>>> _______________________________________________
>>> ldap-sdk-discuss mailing list
>>> lda...@li...
>>> https://lists.sourceforge.net/lists/listinfo/ldap-sdk-discuss
>>>
>>>
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Dive into the World of Parallel Programming. The Go Parallel Website,
>> sponsored by Intel and developed in partnership with Slashdot Media, is
>> your
>> hub for all things parallel software development, from weekly thought
>> leadership blogs to news, videos, case studies, tutorials and more. Take a
>> look and join the conversation now. http://goparallel.sourceforge.net/
>> _______________________________________________
>> ldap-sdk-discuss mailing list
>> lda...@li...
>> https://lists.sourceforge.net/lists/listinfo/ldap-sdk-discuss
>>
>>
>
>
>
>
> ------------------------------------------------------------------------------
> Dive into the World of Parallel Programming. The Go Parallel Website,
> sponsored by Intel and developed in partnership with Slashdot Media, is your
> hub for all things parallel software development, from weekly thought
> leadership blogs to news, videos, case studies, tutorials and more. Take a
> look and join the conversation now. http://goparallel.sourceforge.net/
>
>
>
> _______________________________________________
> ldap-sdk-discuss mailing list
> lda...@li...
> https://lists.sourceforge.net/lists/listinfo/ldap-sdk-discuss
>
|