Author: reschke
Date: Fri Apr 26 12:39:03 2019
New Revision: 1858198
URL: http://svn.apache.org/viewvc?rev=1858198&view=rev
Log:
OAK-8273: RDBDocumentStore: createOrUpdate with less than 3 ops suboptimal
(ported to 1.10)
Modified:
jackrabbit/oak/branches/1.10/ (props changed)
jackrabbit/oak/branches/1.10/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStore.java
Propchange: jackrabbit/oak/branches/1.10/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Apr 26 12:39:03 2019
@@ -1,3 +1,3 @@
/jackrabbit/oak/branches/1.0:1665962
-/jackrabbit/oak/trunk:1850874,1850882,1851236,1851253,1851451,1851533-1851535,1851619,1852052,1852084,1852120,1852451,1852492-1852493,1852528,1852582,1852584,1852601,1852920,1853083,1853141,1853229,1853393,1853429,1853433,1853441,1853866,1853868,1853870,1853893,1853969,1853997,1854034,1854044,1854055,1854058,1854113,1854373,1854377,1854380,1854385,1854401,1854403,1854455,1854461-1854462,1854466,1854468,1854515,1854533,1854539,1854701,1854773-1854774,1854827,1854848,1854859,1854930,1854990-1854991,1855032,1855221,1855477-1855478,1855776,1855993,1856049,1857010,1857104,1857159,1857212,1857221,1857238,1857247,1857253,1857294,1857314,1857577,1857635,1857638,1857640,1857687,1857936,1858032,1858053,1858123
+/jackrabbit/oak/trunk:1850874,1850882,1851236,1851253,1851451,1851533-1851535,1851619,1852052,1852084,1852120,1852451,1852492-1852493,1852528,1852582,1852584,1852601,1852920,1853083,1853141,1853229,1853393,1853429,1853433,1853441,1853866,1853868,1853870,1853893,1853969,1853997,1854034,1854044,1854055,1854058,1854113,1854373,1854377,1854380,1854385,1854401,1854403,1854455,1854461-1854462,1854466,1854468,1854515,1854533,1854539,1854701,1854773-1854774,1854827,1854848,1854859,1854930,1854990-1854991,1855032,1855221,1855477-1855478,1855776,1855993,1856049,1857010,1857104,1857159,1857212,1857221,1857238,1857247,1857253,1857294,1857314,1857577,1857635,1857638,1857640,1857687,1857936,1858032,1858053,1858123,1858139
/jackrabbit/trunk:1345480
Modified:
jackrabbit/oak/branches/1.10/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStore.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.10/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStore.java?rev=1858198&r1=1858197&r2=1858198&view=diff
==============================================================================
---
jackrabbit/oak/branches/1.10/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStore.java
(original)
+++
jackrabbit/oak/branches/1.10/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStore.java
Fri Apr 26 12:39:03 2019
@@ -369,14 +369,22 @@ public class RDBDocumentStore implements
@Override
public <T extends Document> List<T> createOrUpdate(Collection<T>
collection, List<UpdateOp> updateOps) {
- if (!BATCHUPDATES) {
+ // fall back to sequential mode if batches are turned off using system
+ // property, or the number of update operations is small
+ if (!BATCHUPDATES || updateOps.size() < MINIMALBULKUPDATESIZE) {
List<T> results = new ArrayList<T>(updateOps.size());
for (UpdateOp update : updateOps) {
results.add(createOrUpdate(collection, update));
}
return results;
+ } else {
+ return internalCreateOrUpdate(collection, updateOps);
}
+ }
+ private static int MINIMALBULKUPDATESIZE = 3;
+
+ private <T extends Document> List<T> internalCreateOrUpdate(Collection<T>
collection, List<UpdateOp> updateOps) {
final Stopwatch watch = startWatch();
Map<UpdateOp, T> results = new LinkedHashMap<UpdateOp, T>();
Map<String, UpdateOp> operationsToCover = new LinkedHashMap<String,
UpdateOp>();
@@ -402,9 +410,7 @@ public class RDBDocumentStore implements
int i = 0; // iteration count
- // bulk update requires two DB requests, so if we have <= 2 operations
- // it's better to send them sequentially
- while (operationsToCover.size() > 2) {
+ while (operationsToCover.size() >= MINIMALBULKUPDATESIZE) {
// We should try to insert documents only during the first
// iteration. In the 2nd and 3rd iterations we only deal with
// conflicting documents, so they already exist in the database