Commit b3cefaee authored by Hanno Schlichting's avatar Hanno Schlichting

Avoid conflict error hotspot in PluginIndexes' Unindex class by using...

Avoid conflict error hotspot in PluginIndexes' Unindex class by using IITreeSets instead of simple ints from the start. Idea taken from ``enfold.fixes``. This optimizes the common case of FieldIndexes being used for a low number of unique values. The edge-case of having a FieldIndex for an unique value per document gets penalized, as it uses many more persistent objects. This really warrants a separate type of index.
parent c65e3621
...@@ -26,6 +26,10 @@ Bugs Fixed ...@@ -26,6 +26,10 @@ Bugs Fixed
Features Added Features Added
++++++++++++++ ++++++++++++++
- Avoid conflict error hotspot in PluginIndexes' Unindex class by using
IITreeSets instead of simple ints from the start. Idea taken from
``enfold.fixes``.
- Added date range index improvements from ``experimental.catalogqueryplan``. - Added date range index improvements from ``experimental.catalogqueryplan``.
- Changed policy on handling exceptions during ZCML parsing in ``Products``. - Changed policy on handling exceptions during ZCML parsing in ``Products``.
......
...@@ -203,23 +203,20 @@ class UnIndex(SimpleItem): ...@@ -203,23 +203,20 @@ class UnIndex(SimpleItem):
""" """
indexRow = self._index.get(entry, _marker) indexRow = self._index.get(entry, _marker)
# Make sure there's actually a row there already. If not, create # Make sure there's actually a row there already. If not, create
# an IntSet and stuff it in first. # a set and stuff it in first.
if indexRow is _marker: if indexRow is _marker:
self._index[entry] = documentId # We always use a set to avoid getting conflict errors on
# XXX _length needs to be migrated to Length object # multiple threads adding a new row at the same time
try: self._index[entry] = IITreeSet((documentId, ))
self._length.change(1) self._length.change(1)
except AttributeError:
if isinstance(self.__len__, Length):
self._length = self.__len__
del self.__len__
self._length.change(1)
else: else:
try: indexRow.insert(documentId) try:
indexRow.insert(documentId)
except AttributeError: except AttributeError:
# index row is an int # Inline migration: index row with one element was an int at
indexRow=IITreeSet((indexRow, documentId)) # first (before Zope 2.13).
indexRow = IITreeSet((indexRow, documentId))
self._index[entry] = indexRow self._index[entry] = indexRow
def index_object(self, documentId, obj, threshold=None): def index_object(self, documentId, obj, threshold=None):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment