Core: remove per-ID locking when ID was auto-generated
When we know the ID for the document we are about to index was auto-generated, we don't need to acquire/release the per-ID lock, which might provide small speedups during highly concurrent indexing. Closes #6584
This commit is contained in:
parent
ec92646289
commit
15b81c91f7
|
@ -402,13 +402,13 @@ public class InternalEngine extends AbstractIndexShardComponent implements Engin
|
|||
}
|
||||
|
||||
private void innerCreate(Create create, IndexWriter writer) throws IOException {
|
||||
if (optimizeAutoGenerateId && create.autoGeneratedId() && !create.canHaveDuplicates()) {
|
||||
// We don't need to lock because this ID cannot be concurrently updated:
|
||||
innerCreateNoLock(create, writer, Versions.NOT_FOUND, null);
|
||||
} else {
|
||||
synchronized (dirtyLock(create.uid())) {
|
||||
final long currentVersion;
|
||||
final VersionValue versionValue;
|
||||
if (optimizeAutoGenerateId && create.autoGeneratedId() && !create.canHaveDuplicates()) {
|
||||
currentVersion = Versions.NOT_FOUND;
|
||||
versionValue = null;
|
||||
} else {
|
||||
versionValue = versionMap.getUnderLock(create.uid().bytes());
|
||||
if (versionValue == null) {
|
||||
currentVersion = loadCurrentVersionFromIndex(create.uid());
|
||||
|
@ -419,7 +419,12 @@ public class InternalEngine extends AbstractIndexShardComponent implements Engin
|
|||
currentVersion = versionValue.version();
|
||||
}
|
||||
}
|
||||
innerCreateNoLock(create, writer, currentVersion, versionValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void innerCreateNoLock(Create create, IndexWriter writer, long currentVersion, VersionValue versionValue) throws IOException {
|
||||
|
||||
// same logic as index
|
||||
long updatedVersion;
|
||||
|
@ -464,7 +469,6 @@ public class InternalEngine extends AbstractIndexShardComponent implements Engin
|
|||
|
||||
indexingService.postCreateUnderLock(create);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void index(Index index) throws EngineException {
|
||||
|
|
Loading…
Reference in New Issue