From cf9edd4a9111b2c0e0d795694a16420b7d91a28a Mon Sep 17 00:00:00 2001 From: Peter Alfonsi Date: Wed, 25 Oct 2023 13:54:23 -0700 Subject: [PATCH] Misc --- server/build.gradle | 8 ----- .../indices/EhcacheDiskCachingTier.java | 2 -- .../indices/SerializerPerformanceTests.java | 31 +++++++++++++++++-- 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/server/build.gradle b/server/build.gradle index 91d7843eb6116..9c80935634ec9 100644 --- a/server/build.gradle +++ b/server/build.gradle @@ -171,14 +171,6 @@ dependencies { // fst - test only implementation 'de.ruedigermoeller:fst:3.0.4-jdk17' - // these versions based on https://github.com/EsotericSoftware/kryo/tree/master/lib, i dont think it's meant to be built with gradle per se - //api 'com.esotericsoftware.minlog:minlog:1.3.1' - //api 'com.esotericsoftware.reflectasm:reflectasm:1.11.9' - //api 'org.objenesis:objenesis:3.2' - - //api 'com.esotericsoftware.minlog:minlog:1.2' - //api 'com.esotericsoftware.reflectasm:reflectasm:1.09' - //api 'org.objectweb.asm:com.springsource.org.objectweb.asm:3.2.0' testImplementation(project(":test:framework")) { diff --git a/server/src/main/java/org/opensearch/indices/EhcacheDiskCachingTier.java b/server/src/main/java/org/opensearch/indices/EhcacheDiskCachingTier.java index 5a14ba658680f..80d6be4288fb6 100644 --- a/server/src/main/java/org/opensearch/indices/EhcacheDiskCachingTier.java +++ b/server/src/main/java/org/opensearch/indices/EhcacheDiskCachingTier.java @@ -250,9 +250,7 @@ public double getTimeMillisEWMA() { } public IndicesRequestCache.Key convertEhcacheKeyToOriginal(EhcacheKey eKey) throws IOException { - //BytesStreamInput is = new BytesStreamInput(); byte[] bytes = eKey.getBytes(); - //is.readBytes(bytes, 0, bytes.length); BytesStreamInput is = new BytesStreamInput(bytes); try { return indicesRequestCache.new Key(is); diff --git a/server/src/test/java/org/opensearch/indices/SerializerPerformanceTests.java b/server/src/test/java/org/opensearch/indices/SerializerPerformanceTests.java index 4f2cd838fb0d3..685c78672f6d6 100644 --- a/server/src/test/java/org/opensearch/indices/SerializerPerformanceTests.java +++ b/server/src/test/java/org/opensearch/indices/SerializerPerformanceTests.java @@ -13,6 +13,8 @@ package org.opensearch.indices; +//import io.fury.Fury; +//import io.fury.config.Language; import org.nustaq.serialization.FSTObjectInput; import org.nustaq.serialization.FSTObjectOutput; import org.opensearch.common.Randomness; @@ -51,10 +53,10 @@ // Some modifications to related classes also made for ease of testing public class SerializerPerformanceTests extends OpenSearchSingleNodeTestCase { - private final int REPS = 5000000; // how many total times to de/serialize - private final int BATCH_SIZE = 50000; // how many keys to generate at once and time + private final int REPS = 500000; // how many total times to de/serialize + private final int BATCH_SIZE = 5000; // how many keys to generate at once and time private final int NUM_BATCHES = REPS / BATCH_SIZE; - private final int KEY_VALUE_LENGTH = 1000; + private final int KEY_VALUE_LENGTH = 10000; private final String SERIALIZATION_FP = "/Users/petealft/Desktop/serialized.ser"; public SerializerPerformanceTests() { super(); @@ -102,6 +104,14 @@ private byte[][] getEKeyBytes(Random random, InfraHolder infra) throws Exception return eKeyBytes; } + private IndicesRequestCache.Key[] getIRCKeys(Random random, InfraHolder infra) throws Exception { + IndicesRequestCache.Key[] ircKeys = new IndicesRequestCache.Key[BATCH_SIZE]; + for (int i = 0; i < BATCH_SIZE; i++) { + ircKeys[i] = getRandomIRCKey(KEY_VALUE_LENGTH, random, infra.irc, infra.tier, infra.entity); + } + return ircKeys; + } + // splitting these into their own fns, it got clunky and i think all the IO stuff hanging around hurts performance /*private void defaultEhcacheKeySerializer(FileWriter fw, Random random, InfraHolder infra) throws Exception { @@ -166,6 +176,8 @@ private void defaultSerializerHelper(String type, FileWriter fw, Random random, Kryo kryo = new Kryo(); kryo.register(EhcacheKey.class); kryo.register(byte[].class); + //Fury fury = Fury.builder().withLanguage(Language.JAVA).build(); + //fury.register(IndicesRequestCache.Key.class); // will it work? String serializerName = ""; int byteLen = new EhcacheKey(getRandomIRCKey(KEY_VALUE_LENGTH, random, infra.irc, infra.tier, infra.entity)).getBytes().length; switch (type) { @@ -184,6 +196,9 @@ private void defaultSerializerHelper(String type, FileWriter fw, Random random, case "KryoBytes": serializerName = "EhcacheKeyBytesKryo"; break; + case "FuryIRC": + serializerName = "IRCKeyFury"; + break; /*case "FST": serializerName = "EhcacheKeyFST"; break;*/ @@ -193,6 +208,7 @@ private void defaultSerializerHelper(String type, FileWriter fw, Random random, System.gc(); EhcacheKey[] eKeys = null; byte[][] eKeyBytes = null; + IndicesRequestCache.Key[] ircKeys = null; switch (type) { case "EhcacheKey": @@ -204,6 +220,9 @@ private void defaultSerializerHelper(String type, FileWriter fw, Random random, case "KryoBytes": eKeyBytes = getEKeyBytes(random, infra); break; + case "FuryIRC": + ircKeys = getIRCKeys(random, infra); + break; } // https://www.geeksforgeeks.org/serialization-in-java/ @@ -236,6 +255,11 @@ private void defaultSerializerHelper(String type, FileWriter fw, Random random, kryo.writeObject(kryoOutput, eKeyBytes[i]); } break; + /*case "FuryIRC": + for (int i = 0; i < BATCH_SIZE; i++) { + byte[] bytes = fury.serialize(ircKeys[i]); // also add to file later if it works + } + break;*/ /*case "FST": for (int i = 0; i < BATCH_SIZE; i++) { fstOut.writeObject(eKeys[i], EhcacheKey.class); @@ -321,6 +345,7 @@ public void testEhcacheKeySerializers() throws Exception { //defaultSerializerHelper("IRCKey", fw, random, infra); // have to make a Bunch of stuff serializable to enable this, but just to check... //defaultSerializerHelper("FST", fw, random, infra); + //defaultSerializerHelper("FuryIRC", fw, random, infra); defaultSerializerHelper("Kryo", fw, random, infra); defaultSerializerHelper("KryoBytes", fw, random, infra); defaultSerializerHelper("EhcacheBytes", fw, random, infra);