Details
-
Bug
-
Resolution: Unresolved
-
Major
-
None
-
None
-
None
-
None
-
2
Description
The FIT performance project is seeing ~4x slower. A small benchmark app is seeing ~2x slower. But essentially - a readonly transaction should be about as fast as KV gets, and they don't seem to be.
Reproduction
Some very basic code that does some JVM warmup but doesn't try to use JMH or similar to do profiling 'properly', is here:
@Test
|
void benchmark() {
|
// JVM warmup
|
doBenchmark(100);
|
// For reals
|
doBenchmark(10000);
|
}
|
|
private static void doBenchmark(int base) {
|
String docId = UUID.randomUUID().toString();
|
JsonObject content = JsonObject.create().put("foo", "bar");
|
collection.insert(docId, content);
|
|
transactions(docId, base); kvGet(docId, base);
|
lookupIn(docId, base);
|
justGetDoc(docId, base);
|
}
|
|
private static void justGetDoc(String docId, int base) {
|
long start;
|
start = System.nanoTime();
|
MeteringUnits.MeteringUnitsBuilder units = new MeteringUnits.MeteringUnitsBuilder();
|
for (int i = 0; i < base; i++) {
|
DocumentGetter.justGetDoc(cluster.core(),
|
CollectionIdentifier.fromDefault(collection.bucketName()),
|
docId,
|
Duration.ofSeconds(2),
|
null,
|
true,
|
null,
|
units).block();
|
}
|
System.out.println("JustGetDoc took " + TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start));
|
}private static void kvGet(String docId, int base) {
|
long start;
|
start = System.nanoTime();
|
for (int i = 0; i < base; i++) {
|
collection.get(docId);
|
}
|
System.out.println("Full-doc get took " + TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start));
|
}
|
private static void lookupIn(String docId, int base) {
|
long start;
|
start = System.nanoTime();
|
for (int i = 0; i < base; i++) {
|
collection.lookupIn(docId, CbCollections.listOf(LookupInSpec.get(""), LookupInSpec.get("txn").xattr()));
|
}
|
System.out.println("Subdoc took " + TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start));
|
}
|
|
private static void transactions(String docId, int base) {
|
long start = System.nanoTime();
|
for (int i = 0; i < base; i++) {
|
cluster.transactions().run((ctx) -> {
|
ctx.get(collection, docId);
|
});
|
}
|
System.out.println("Transactions took " + TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start));
|
}
|
|