OPENDJ-2709 Reduce lock contention in SubentryManager for modify/delete requests
For modify operations return immediately if the operation does not
target a sub-entry (lock-free). For delete operations return immediately
if the targeted entry is not a sub-tree containing sub-entries (requires
shared lock). This change improves modify throughput by over 50% against
an in-memory backend.
In DITCacheMap: make DITSubtreeSet.isEmpty() O(1) instead of O(N).
| | |
| | | } |
| | | |
| | | @Override |
| | | public boolean isEmpty() |
| | | { |
| | | return !(new SubtreeSetIterator(this.key).hasNext()); |
| | | } |
| | | |
| | | @Override |
| | | public int size() |
| | | { |
| | | int size = 0; |
| | |
| | | |
| | | private void doPostDelete(Entry entry) |
| | | { |
| | | // Fast-path for deleted entries which do not have subordinate sub-entries. |
| | | lock.readLock().lock(); |
| | | try |
| | | { |
| | | final Collection<SubEntry> subtree = dit2SubEntry.getSubtree(entry.getName()); |
| | | if (subtree.isEmpty()) |
| | | { |
| | | return; |
| | | } |
| | | } |
| | | finally |
| | | { |
| | | lock.readLock().unlock(); |
| | | } |
| | | |
| | | // Slow-path. |
| | | lock.writeLock().lock(); |
| | | try |
| | | { |
| | |
| | | { |
| | | final boolean oldEntryIsSubentry = isSubEntry(oldEntry); |
| | | final boolean newEntryIsSubentry = isSubEntry(newEntry); |
| | | if (!oldEntryIsSubentry && !newEntryIsSubentry) |
| | | { |
| | | return; // Nothing to do. |
| | | } |
| | | |
| | | boolean notify = false; |
| | | lock.writeLock().lock(); |
| | | try |