Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor to Client-Manager-Connection layers #42

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
06574ea
Add Jedis and Lettuce benchmarks
jonathanl-bq Sep 7, 2023
5990767
Start ignoring .gradle files
jonathanl-bq Sep 8, 2023
6ae93f5
Update gitignore and remove generated files from git
acarbonetto Oct 3, 2023
8203c4d
Update gitignore and remove generated files from git
acarbonetto Sep 8, 2023
e517744
Update gitignore and remove generated files from git
acarbonetto Sep 8, 2023
2a11e9a
Add benchmarks for GET non-existing
jonathanl-bq Sep 8, 2023
cbb0dcb
Revert "Update gitignore and remove generated files from git"
acarbonetto Sep 8, 2023
5f51a5b
fix redis-rs submodules
acarbonetto Sep 8, 2023
52df672
Randomize commands in Java benchmarks
jonathanl-bq Sep 13, 2023
84f0efc
rename chooseAction to randomAction
jonathanl-bq Sep 14, 2023
1983974
Add a Java benchmarking app (#7)
acarbonetto Sep 20, 2023
6c1fb45
Add Readme and update install_and_test script to runJava
acarbonetto Sep 20, 2023
46d0cf6
Add Readme and update install_and_test script to runJava
acarbonetto Sep 20, 2023
d526f96
Combine java pipeline and java benchmarks (#8)
Yury-Fridlyand Sep 22, 2023
436da8f
Add sync and async clients both to tests. (#12)
Yury-Fridlyand Sep 25, 2023
016f5f6
Move duplicated logic in benchmark JS scripts to a single file, and c…
acarbonetto Sep 25, 2023
e57c1ff
Add dataSize option to java benchmark. (#11)
Yury-Fridlyand Sep 26, 2023
8664d05
Rename jabushka to javababushka (#14)
acarbonetto Sep 26, 2023
b15f93e
Add missing renames. (#17)
Yury-Fridlyand Sep 27, 2023
1bab56a
Add option to run tests on multiple clients in concurrency (#16)
Yury-Fridlyand Oct 5, 2023
d99d27a
Update redis-rs to match main branch
acarbonetto Oct 6, 2023
540f49a
Create clients only once per iteration (#19)
acarbonetto Oct 6, 2023
035ef20
Add Java-client benchmarking app
acarbonetto Oct 10, 2023
0883985
spotless apply
acarbonetto Oct 10, 2023
d15ade1
Update on command line options
acarbonetto Oct 10, 2023
e3634ba
Update README
acarbonetto Oct 10, 2023
500a043
Spotless apply:
acarbonetto Oct 10, 2023
0bf1678
Update README example
acarbonetto Oct 11, 2023
12efc63
update commandline defaults for review comments
acarbonetto Oct 11, 2023
951aa8b
Remove TLS flag argument from option
acarbonetto Oct 11, 2023
adc0bb6
Add lettuce clients for benchmarking
acarbonetto Oct 10, 2023
9fc9022
Spotless apply
acarbonetto Oct 10, 2023
111fc26
Add Jedis clients
acarbonetto Oct 10, 2023
9236e9a
Add to app
acarbonetto Oct 10, 2023
49654c3
Add for-loop for data size list
acarbonetto Oct 10, 2023
b3284c1
Add TPS for all async items
acarbonetto Oct 11, 2023
8f1dfa5
spotless apply
acarbonetto Oct 11, 2023
7f690cf
Fix TPS calculations
acarbonetto Oct 11, 2023
d00a655
Accept TLS as a flag
acarbonetto Oct 11, 2023
b5e9a33
Merge branch 'java-client/add_benchmark_app' into java-client/add_jed…
acarbonetto Oct 11, 2023
3cee673
Merge branch 'java-client/add_jedis_client' into java-client/add_tps
acarbonetto Oct 11, 2023
8dcfec0
Start threads; then wait for results
acarbonetto Oct 12, 2023
a615f8a
Add java-jni client
acarbonetto Oct 18, 2023
73c448f
Handle Exceptions from client; add JniSyncClient fixes
acarbonetto Oct 19, 2023
79459f5
Clean up latency and add error checking
acarbonetto Oct 20, 2023
c3d235a
Add json reporting. (#10)
Yury-Fridlyand Oct 20, 2023
917dd0e
Merge remote-tracking branch 'origin/java_benchmarks' into java-clien…
Yury-Fridlyand Oct 24, 2023
9e62324
Minor fixes.
Yury-Fridlyand Oct 24, 2023
11a78a3
Fix result printing.
Yury-Fridlyand Oct 25, 2023
a2c2670
Add TPS.
Yury-Fridlyand Oct 25, 2023
4b9f8de
Remove duplicates. Reorganize and fix imports.
Yury-Fridlyand Oct 25, 2023
d6b72ac
Int ctor fix.
Yury-Fridlyand Oct 26, 2023
58f7b58
Iteration 1.
Yury-Fridlyand Oct 31, 2023
d145bdf
Iteration 2: connected!
Yury-Fridlyand Oct 31, 2023
0b03dc5
Iteration 3: `get` and `set`.
Yury-Fridlyand Nov 1, 2023
a3075d5
Iteration 4: benchmark.
Yury-Fridlyand Nov 1, 2023
5f10964
Iteration 5: some fixes.
Yury-Fridlyand Nov 2, 2023
e3f7596
Change number of threads in Benchmarking threadpool
jonathanl-bq Nov 2, 2023
49c9119
Revert "Change number of threads in Benchmarking threadpool"
jonathanl-bq Nov 2, 2023
dd7413b
Add more flushing rules and UT.
Yury-Fridlyand Nov 3, 2023
a70c907
Client clean up.
Yury-Fridlyand Nov 16, 2023
14d392b
try to split client - receiving unknown callback id
Yury-Fridlyand Nov 16, 2023
058a05c
Iteration 2 - try to use a singleton-like approach.
Yury-Fridlyand Nov 20, 2023
dfbd106
Fix thread pool use for Netty.
Yury-Fridlyand Nov 24, 2023
ea30ea1
Revert some core lib changes.
Yury-Fridlyand Nov 24, 2023
9edb6be
Merge remote-tracking branch 'origin/integ-java-client-milestone-1' i…
Yury-Fridlyand Nov 24, 2023
986f468
Revert some changes added by mistake.
Yury-Fridlyand Nov 24, 2023
d58bff9
Address PR feedback.
Yury-Fridlyand Nov 27, 2023
507ef9f
Fix generating callback ID and handling new connections.
Yury-Fridlyand Nov 27, 2023
9cecf23
Revert IT.
Yury-Fridlyand Nov 28, 2023
8ffdbea
Add unit tests for Client
acarbonetto Nov 29, 2023
4ecd5d8
Implement Bulk value case in FFI layer
jonathanl-bq Nov 29, 2023
2bf997e
More split.
Yury-Fridlyand Nov 30, 2023
1aa0707
Renaming
Yury-Fridlyand Nov 30, 2023
14e3e18
Fix build.
Yury-Fridlyand Nov 30, 2023
6d2ae81
Clean up commented logging.
Yury-Fridlyand Nov 30, 2023
e7ee9a9
Javadoc
Yury-Fridlyand Nov 30, 2023
540120e
Revert some renamings.
Yury-Fridlyand Nov 30, 2023
aa5aa52
Optimize a bit.
Yury-Fridlyand Nov 30, 2023
5481dc2
Refactor to Client-Manager-Connection layers
acarbonetto Dec 1, 2023
667d277
Update refactor to include client factory builders
acarbonetto Dec 1, 2023
537d538
Add unit tests for API
acarbonetto Dec 1, 2023
2f81317
Clean up sync calls; add close connection
acarbonetto Dec 2, 2023
e828f0c
Update for review comments
acarbonetto Dec 4, 2023
3086e6f
Applying some fixes from `dev-split-netty-client` branch.
Yury-Fridlyand Dec 6, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions babushka-core/src/socket_listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ async fn write_result(
error_message.into(),
))
} else {
log_warn("received error", error_message.as_str());
log_warn("received error", format!("{} for callback {}", error_message.as_str(), callback_index));
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should revert this

let mut request_error = response::RequestError::default();
if err.is_connection_dropped() {
request_error.type_ = response::RequestErrorType::Disconnect.into();
Expand Down Expand Up @@ -476,7 +476,7 @@ fn handle_request(request: RedisRequest, client: Client, writer: Rc<Writer>) {
}
},
None => Err(ClienUsageError::InternalError(
"Received empty request".to_string(),
format!("Received empty request for callback {}", request.callback_idx),
)),
};

Expand Down
4 changes: 2 additions & 2 deletions java/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
# Ignore Gradle build output directory
build

# Ignore generated files (e.g. protobuf)
generated
# Ignore protobuf generated files
protobuf
6 changes: 3 additions & 3 deletions java/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ language api to enhance performance and limit cpu cycles at scale.

## Organization

The Java client (javababushka) contains the following parts:
The Java client contains the following parts:

1. A Java client (lib folder): wrapper to rust-client.
2. An examples script: to sanity test javababushka and similar java-clients against a redis host.
3. A benchmark app: to performance benchmark test javababushka and similar java-clients against a redis host.
2. An examples script: to sanity test babushka and similar java-clients against a redis host.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Babushka"... but honestly, we have to change this anyways.

3. A benchmark app: to performance benchmark test babushka and similar java-clients against a redis host.

## Building

Expand Down
4 changes: 1 addition & 3 deletions java/benchmarks/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ dependencies {
// Use JUnit test framework.
testImplementation 'org.junit.jupiter:junit-jupiter:5.9.2'

// This dependency is used internally, and not exposed to consumers on their own compile classpath.
implementation 'com.google.guava:guava:32.1.1-jre'
implementation 'redis.clients:jedis:4.4.3'
implementation 'io.lettuce:lettuce-core:6.2.6.RELEASE'
implementation 'commons-cli:commons-cli:1.5.0'
Expand All @@ -36,7 +34,7 @@ java {

application {
// Define the main class for the application.
mainClass = 'javababushka.benchmarks.BenchmarkingApp'
mainClass = 'babushka.benchmarks.BenchmarkingApp'
applicationDefaultJvmArgs += "-Djava.library.path=${projectDir}/../target/release:${projectDir}/../target/debug"
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package javababushka.benchmarks;

import static javababushka.benchmarks.utils.Benchmarking.testClientSetGet;

package babushka.benchmarks;

import babushka.benchmarks.clients.babushka.JniNettyClient;
import babushka.benchmarks.clients.jedis.JedisClient;
import babushka.benchmarks.clients.jedis.JedisPseudoAsyncClient;
import babushka.benchmarks.clients.lettuce.LettuceAsyncClient;
import babushka.benchmarks.clients.lettuce.LettuceAsyncClusterClient;
import babushka.benchmarks.clients.lettuce.LettuceClient;
import babushka.benchmarks.utils.Benchmarking;
import java.util.Arrays;
import java.util.Optional;
import java.util.stream.Stream;
import javababushka.benchmarks.clients.babushka.JniNettyClient;
import javababushka.benchmarks.clients.jedis.JedisClient;
import javababushka.benchmarks.clients.jedis.JedisPseudoAsyncClient;
import javababushka.benchmarks.clients.lettuce.LettuceAsyncClient;
import javababushka.benchmarks.clients.lettuce.LettuceAsyncClusterClient;
import javababushka.benchmarks.clients.lettuce.LettuceClient;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.DefaultParser;
Expand All @@ -36,7 +35,7 @@ public static void main(String[] args) {
// generate the help statement
if (line.hasOption("help")) {
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("javababushka", options);
formatter.printHelp("babushka", options);
return;
}

Expand All @@ -50,27 +49,27 @@ public static void main(String[] args) {
switch (client) {
case JEDIS:
// run testClientSetGet on JEDIS sync client
testClientSetGet(JedisClient::new, runConfiguration, false);
Benchmarking.testClientSetGet(JedisClient::new, runConfiguration, false);
break;
case JEDIS_ASYNC:
// run testClientSetGet on JEDIS pseudo-async client
testClientSetGet(JedisPseudoAsyncClient::new, runConfiguration, true);
Benchmarking.testClientSetGet(JedisPseudoAsyncClient::new, runConfiguration, true);
break;
case LETTUCE:
testClientSetGet(LettuceClient::new, runConfiguration, false);
Benchmarking.testClientSetGet(LettuceClient::new, runConfiguration, false);
break;
case LETTUCE_ASYNC:
if (runConfiguration.clusterModeEnabled) {
testClientSetGet(LettuceAsyncClusterClient::new, runConfiguration, true);
Benchmarking.testClientSetGet(LettuceAsyncClusterClient::new, runConfiguration, true);
} else {
testClientSetGet(LettuceAsyncClient::new, runConfiguration, true);
Benchmarking.testClientSetGet(LettuceAsyncClient::new, runConfiguration, true);
}
break;
case BABUSHKA:
testClientSetGet(() -> new JniNettyClient(false), runConfiguration, false);
Benchmarking.testClientSetGet(() -> new JniNettyClient(false), runConfiguration, false);
break;
case BABUSHKA_ASYNC:
testClientSetGet(() -> new JniNettyClient(true), runConfiguration, true);
Benchmarking.testClientSetGet(() -> new JniNettyClient(true), runConfiguration, true);
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package javababushka.benchmarks.clients;
package babushka.benchmarks.clients;

import babushka.benchmarks.utils.ConnectionSettings;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import javababushka.benchmarks.utils.ConnectionSettings;

/** A Redis client with async capabilities */
public interface AsyncClient<T> extends Client {
Expand All @@ -13,7 +13,7 @@ public interface AsyncClient<T> extends Client {

Future<T> asyncSet(String key, String value);

Future<String> asyncGet(String key);
Future<T> asyncGet(String key);

default <T> T waitForResult(Future<T> future) {
return waitForResult(future, DEFAULT_TIMEOUT_MILLISECOND);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package javababushka.benchmarks.clients;
package babushka.benchmarks.clients;

import javababushka.benchmarks.utils.ConnectionSettings;
import babushka.benchmarks.utils.ConnectionSettings;

/** A Redis client interface */
public interface Client {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package javababushka.benchmarks.clients;
package babushka.benchmarks.clients;

/** A Redis client with sync capabilities */
public interface SyncClient extends Client {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package babushka.benchmarks.clients.babushka;

import babushka.api.Awaiter;
import babushka.api.Client;
import babushka.api.Commands;
import babushka.api.Connection;
import babushka.benchmarks.clients.AsyncClient;
import babushka.benchmarks.clients.SyncClient;
import babushka.benchmarks.utils.ConnectionSettings;
import java.util.concurrent.Future;

public class JniNettyClient implements SyncClient, AsyncClient {

private final Connection connection;
private final Commands asyncCommands;

private String name = "JNI Netty";

public JniNettyClient(boolean async) {
name += async ? " async" : " sync";
connection = Client.CreateConnection();
asyncCommands = Client.GetAsyncCommands(connection);
}

@Override
public String getName() {
return name;
}

@Override
public void connectToRedis() {
connectToRedis(new ConnectionSettings("localhost", 6379, false, false));
}

@Override
public void connectToRedis(ConnectionSettings connectionSettings) {
waitForResult(asyncConnectToRedis(connectionSettings));
}

@Override
public Future<Boolean> asyncConnectToRedis(ConnectionSettings connectionSettings) {
return connection.connectToRedis(
connectionSettings.host,
connectionSettings.port,
connectionSettings.useSsl,
connectionSettings.clusterMode);
}

@Override
public Future<String> asyncSet(String key, String value) {
return asyncCommands.set(key, value);
}

@Override
public Future<String> asyncGet(String key) {
return asyncCommands.get(key);
}

@Override
public void set(String key, String value) {
Awaiter.await(asyncCommands.set(key, value));
}

@Override
public String get(String key) {
return Awaiter.await(asyncCommands.get(key));
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package javababushka.benchmarks.clients.jedis;
package babushka.benchmarks.clients.jedis;

import javababushka.benchmarks.clients.SyncClient;
import javababushka.benchmarks.utils.ConnectionSettings;
import babushka.benchmarks.clients.SyncClient;
import babushka.benchmarks.utils.ConnectionSettings;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package javababushka.benchmarks.clients.jedis;
package babushka.benchmarks.clients.jedis;

import babushka.benchmarks.clients.AsyncClient;
import babushka.benchmarks.utils.ConnectionSettings;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Future;
import javababushka.benchmarks.clients.AsyncClient;
import javababushka.benchmarks.utils.ConnectionSettings;

/**
* A Jedis client with pseudo-async capabilities. Jedis doesn't provide async API
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package javababushka.benchmarks.clients.lettuce;
package babushka.benchmarks.clients.lettuce;

import babushka.benchmarks.clients.AsyncClient;
import babushka.benchmarks.utils.ConnectionSettings;
import io.lettuce.core.RedisClient;
import io.lettuce.core.RedisFuture;
import io.lettuce.core.RedisURI;
import io.lettuce.core.api.StatefulRedisConnection;
import io.lettuce.core.api.async.RedisAsyncCommands;
import io.lettuce.core.codec.StringCodec;
import java.util.concurrent.Future;
import javababushka.benchmarks.clients.AsyncClient;
import javababushka.benchmarks.utils.ConnectionSettings;

/** A Lettuce client with async capabilities see: https://lettuce.io/ */
public class LettuceAsyncClient implements AsyncClient<String> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/*
* This Java source file was generated by the Gradle 'init' task.
*/
package javababushka.benchmarks.clients.lettuce;
package babushka.benchmarks.clients.lettuce;

import babushka.benchmarks.utils.ConnectionSettings;
import io.lettuce.core.RedisFuture;
import io.lettuce.core.RedisURI;
import io.lettuce.core.cluster.RedisClusterClient;
import io.lettuce.core.cluster.api.StatefulRedisClusterConnection;
import io.lettuce.core.cluster.api.async.RedisAdvancedClusterAsyncCommands;
import javababushka.benchmarks.utils.ConnectionSettings;

public class LettuceAsyncClusterClient extends LettuceAsyncClient {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package javababushka.benchmarks.clients.lettuce;
package babushka.benchmarks.clients.lettuce;

import babushka.benchmarks.clients.SyncClient;
import babushka.benchmarks.utils.ConnectionSettings;
import io.lettuce.core.RedisClient;
import io.lettuce.core.api.StatefulRedisConnection;
import io.lettuce.core.api.sync.RedisStringCommands;
import javababushka.benchmarks.clients.SyncClient;
import javababushka.benchmarks.utils.ConnectionSettings;

/** A Lettuce client with sync capabilities see: https://lettuce.io/ */
public class LettuceClient implements SyncClient {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package javababushka.benchmarks.utils;
package babushka.benchmarks.utils;

import babushka.benchmarks.BenchmarkingApp;
import babushka.benchmarks.clients.AsyncClient;
import babushka.benchmarks.clients.Client;
import babushka.benchmarks.clients.SyncClient;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
Expand All @@ -11,10 +15,6 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Supplier;
import javababushka.benchmarks.BenchmarkingApp;
import javababushka.benchmarks.clients.AsyncClient;
import javababushka.benchmarks.clients.Client;
import javababushka.benchmarks.clients.SyncClient;
import org.apache.commons.lang3.tuple.Pair;

/** Class to calculate latency on client-actions */
Expand Down Expand Up @@ -127,6 +127,7 @@ public static void printResults(
System.out.printf("Iterations: %d%n", iterations);
System.out.printf("TPS: %f%n", iterations / duration);
int totalHits = 0;

for (Map.Entry<ChosenAction, LatencyResults> entry : resultsMap.entrySet()) {
ChosenAction action = entry.getKey();
LatencyResults results = entry.getValue();
Expand All @@ -140,7 +141,7 @@ public static void printResults(
System.out.printf("Total hits: %d%n", results.totalHits);
totalHits += results.totalHits;
}
System.out.println("Total hits: " + totalHits);
System.out.printf("%nTotal hits: %d%n", totalHits);
}

public static void testClientSetGet(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package javababushka.benchmarks.utils;
package babushka.benchmarks.utils;

public enum ChosenAction {
GET_NON_EXISTING,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package javababushka.benchmarks.utils;
package babushka.benchmarks.utils;

import lombok.AllArgsConstructor;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package javababushka.benchmarks.utils;
package babushka.benchmarks.utils;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package javababushka.benchmarks.utils;
package babushka.benchmarks.utils;

import lombok.AllArgsConstructor;

Expand Down
Loading
Loading