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

Java: Add ExamplesApp and Update benchmarkingApp to both have Java/Glide-for-redis client #896

Merged

Conversation

acarbonetto
Copy link
Contributor

Issue #, if available:

Description of changes:

Add the Glide async client to the BenchmarkApp for the install_and_test script.
Add the ExamplesApp for manually testing custom commands.

Out of scope

Glide async client doesn't have cluster-mode client linked (TODO).
ExamplesApp runs only custom command (no transactions, no specific commands - TODO).

Examples:

To run benchmark app, run:

./gradlew :benchmarks:run --args="-clients GLIDE -dataSize 100 -concurrentTasks 100 -clientCount 1"

To run examples app, run:

./gradlew :examples:run

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@acarbonetto acarbonetto added the java issues and fixes related to the java client label Feb 2, 2024
@acarbonetto acarbonetto self-assigned this Feb 2, 2024
@acarbonetto acarbonetto requested a review from a team as a code owner February 2, 2024 07:20
java/README.md Outdated Show resolved Hide resolved
java/README.md Show resolved Hide resolved
java/benchmarks/build.gradle Show resolved Hide resolved
System.out.println("Run LETTUCE async client");
testClientSetGet(LettuceAsyncClient::new, runConfiguration, true);
break;
case GLIDE:
System.out.println("GLIDE for Redis async not yet configured");
System.out.println("Run GLIDE async client");
Copy link
Collaborator

Choose a reason for hiding this comment

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

woohoo
does it run in CI?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No. Does it need to?

Copy link
Collaborator

Choose a reason for hiding this comment

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

https://github.com/aws/glide-for-redis/blob/main/.github/workflows/java-benchmark.yml
It runs on demand only. Can you trigger it and validate that it works?

Copy link
Contributor Author

@acarbonetto acarbonetto Feb 9, 2024

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh you need to add protobuf installation to benchmarking CI
Please update it to let CI pass and generate numbers.

java/examples/build.gradle Outdated Show resolved Hide resolved
@@ -0,0 +1,25 @@
plugins {
Copy link
Contributor

Choose a reason for hiding this comment

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

examples should be under the ${root}/examples folder, not under the java folder. This reduces the user's ability to find the app.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This adds difficulties on dependency resolution (line 12), until java client released to maven.
But I think it is possible to commit a directory symlink. @acarbonetto can you try this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will try.
Ultimately, we want to be able to create a distribution JAR, and at that point a separate gradle project may be fine.


@Override
public CompletableFuture<String> asyncSet(String key, String value) {
return redisClient.customCommand(new String[] {"Set", key, value}).thenApply(r -> "Ok");
Copy link
Contributor

Choose a reason for hiding this comment

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

why do you modify the returned value?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Previous iterations of the client returned null.
This is no longer true, and now the client returns "OK".
Fixed.

java/README.md Outdated Show resolved Hide resolved
@shachlanAmazon
Copy link
Contributor

I pulled this PR, ran ./install_and_test.sh -java -only-glide -tasks 500 -data 100 -no-tls and got

> Task :benchmarks:run FAILED
Run GLIDE async client
Exception in thread "main" java.lang.UnsatisfiedLinkError: no glide_rs in java.library.path: [../target/release]
        at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2678)
        at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:830)
        at java.base/java.lang.System.loadLibrary(System.java:1886)
        at glide.ffi.resolvers.SocketListenerResolver.<clinit>(SocketListenerResolver.java:11)
        at glide.api.BaseClient.buildChannelHandler(BaseClient.java:84)
        at glide.api.BaseClient.CreateClient(BaseClient.java:50)
        at glide.api.RedisClient.CreateClient(RedisClient.java:28)
        at glide.benchmarks.clients.glide.GlideAsyncClient.connectToRedis(GlideAsyncClient.java:32)
        at glide.benchmarks.utils.Benchmarking.testClientSetGet(Benchmarking.java:118)
        at glide.benchmarks.BenchmarkingApp.main(BenchmarkingApp.java:59)

FAILURE: Build failed with an exception.

@acarbonetto acarbonetto closed this Feb 9, 2024
@acarbonetto acarbonetto force-pushed the java/integ_acarbo_add_examples_benchmarking branch from ceb0144 to ceaa793 Compare February 9, 2024 07:13
@acarbonetto acarbonetto reopened this Feb 9, 2024
@acarbonetto
Copy link
Contributor Author

acarbonetto commented Feb 9, 2024

I pulled this PR, ran ./install_and_test.sh -java -only-glide -tasks 500 -data 100 -no-tls and got

> Task :benchmarks:run FAILED
Run GLIDE async client
Exception in thread "main" java.lang.UnsatisfiedLinkError: no glide_rs in java.library.path: [../target/release]
        at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2678)
        at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:830)
        at java.base/java.lang.System.loadLibrary(System.java:1886)
        at glide.ffi.resolvers.SocketListenerResolver.<clinit>(SocketListenerResolver.java:11)
        at glide.api.BaseClient.buildChannelHandler(BaseClient.java:84)
        at glide.api.BaseClient.CreateClient(BaseClient.java:50)
        at glide.api.RedisClient.CreateClient(RedisClient.java:28)
        at glide.benchmarks.clients.glide.GlideAsyncClient.connectToRedis(GlideAsyncClient.java:32)
        at glide.benchmarks.utils.Benchmarking.testClientSetGet(Benchmarking.java:118)
        at glide.benchmarks.BenchmarkingApp.main(BenchmarkingApp.java:59)

FAILURE: Build failed with an exception.

It didn't build the rustn library. I have added a dependency on the run task to compile rust release first. This should now work out of the box.

I ran:

glide/benchmarks> ./install_and_test.sh -java -only-glide -tasks 100 -data 100 -no-tls

and got:

> Task :client:buildRustRelease
    Finished release [optimized + debuginfo] target(s) in 0.19s

> Task :benchmarks:run
GLIDE for Redis async client
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

 =====> Glide Async <===== 1 clients 100 concurrent 100 data size 

Runtime s: 5.473331
Iterations: 1000000
TPS: 182704.083490
===> SET <===
avg. time ms: 0.000544
std dev ms: 0.000244
p50 latency ms: 0.000518
p90 latency ms: 0.000591
p99 latency ms: 0.000994
Total hits: 200212
===> GET_NON_EXISTING <===
avg. time ms: 0.000544
std dev ms: 0.000250
p50 latency ms: 0.000518
p90 latency ms: 0.000591
p99 latency ms: 0.000990
Total hits: 159560
===> GET_EXISTING <===
avg. time ms: 0.000545
std dev ms: 0.000256
p50 latency ms: 0.000518
p90 latency ms: 0.000591
p99 latency ms: 0.000999
Total hits: 640228
Total hits: 1000000


> Task :examples:run
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Glide PING: PONG
Glide PING: found you

...note: I'll remove the examples:run :D from the install_and_test script.

.github/workflows/java-benchmark.yml Show resolved Hide resolved
@@ -0,0 +1,25 @@
plugins {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This adds difficulties on dependency resolution (line 12), until java client released to maven.
But I think it is possible to commit a directory symlink. @acarbonetto can you try this?

acarbonetto and others added 8 commits February 12, 2024 21:30
Signed-off-by: Andrew Carbonetto <[email protected]>
Signed-off-by: Andrew Carbonetto <[email protected]>
Signed-off-by: Andrew Carbonetto <[email protected]>
Signed-off-by: Yury-Fridlyand <[email protected]>
Signed-off-by: Andrew Carbonetto <[email protected]>
Signed-off-by: Andrew Carbonetto <[email protected]>
Signed-off-by: Andrew Carbonetto <[email protected]>
Signed-off-by: Andrew Carbonetto <[email protected]>
@acarbonetto acarbonetto force-pushed the java/integ_acarbo_add_examples_benchmarking branch from 2fa01c2 to 2259992 Compare February 13, 2024 17:47
Signed-off-by: Andrew Carbonetto <[email protected]>
Signed-off-by: Andrew Carbonetto <[email protected]>

System.out.println("SET(apples, oranges): " + client.set("apples", "oranges").get());
System.out.println("GET(apples): " + client.get("apples").get());

Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it worth adding an example with an error?

@acarbonetto acarbonetto merged commit 7292960 into valkey-io:main Feb 15, 2024
11 checks passed
@acarbonetto acarbonetto deleted the java/integ_acarbo_add_examples_benchmarking branch February 15, 2024 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
java issues and fixes related to the java client
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants