Skip to content

Commit

Permalink
Misc
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Alfonsi committed Oct 25, 2023
1 parent 814ed49 commit cf9edd4
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 13 deletions.
8 changes: 0 additions & 8 deletions server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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) {
Expand All @@ -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;*/
Expand All @@ -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":
Expand All @@ -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/
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit cf9edd4

Please sign in to comment.