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 {
|
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())) {
|
synchronized (dirtyLock(create.uid())) {
|
||||||
final long currentVersion;
|
final long currentVersion;
|
||||||
final VersionValue versionValue;
|
final VersionValue versionValue;
|
||||||
if (optimizeAutoGenerateId && create.autoGeneratedId() && !create.canHaveDuplicates()) {
|
|
||||||
currentVersion = Versions.NOT_FOUND;
|
|
||||||
versionValue = null;
|
|
||||||
} else {
|
|
||||||
versionValue = versionMap.getUnderLock(create.uid().bytes());
|
versionValue = versionMap.getUnderLock(create.uid().bytes());
|
||||||
if (versionValue == null) {
|
if (versionValue == null) {
|
||||||
currentVersion = loadCurrentVersionFromIndex(create.uid());
|
currentVersion = loadCurrentVersionFromIndex(create.uid());
|
||||||
|
@ -419,7 +419,12 @@ public class InternalEngine extends AbstractIndexShardComponent implements Engin
|
||||||
currentVersion = versionValue.version();
|
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
|
// same logic as index
|
||||||
long updatedVersion;
|
long updatedVersion;
|
||||||
|
@ -464,7 +469,6 @@ public class InternalEngine extends AbstractIndexShardComponent implements Engin
|
||||||
|
|
||||||
indexingService.postCreateUnderLock(create);
|
indexingService.postCreateUnderLock(create);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void index(Index index) throws EngineException {
|
public void index(Index index) throws EngineException {
|
||||||
|
|
Loading…
Reference in New Issue