-
Notifications
You must be signed in to change notification settings - Fork 39
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
Http Client benchmark #527
Open
TingDaoK
wants to merge
42
commits into
main
Choose a base branch
from
http-canary
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
a81617e
http client canary
TingDaoK 9dbebd5
add mvn exec
TingDaoK d9ad783
use per sec
TingDaoK facd3f6
make it more clear
TingDaoK 3806aa6
fix build
TingDaoK cffc9f1
Merge branch 'main' into http-canary
TingDaoK 6d6c628
add netty client
TingDaoK fe083a8
let's try to run it from CI for now
TingDaoK 7f8eecb
oh my
TingDaoK f51b463
install first?
TingDaoK 892c64b
do we change dir succeed?
TingDaoK ed7d1d7
Revert "do we change dir succeed?"
TingDaoK c30a8f8
check it out
TingDaoK 1a1be3f
what about this?
TingDaoK b74df4e
Revert "what about this?"
TingDaoK 4115ede
again
TingDaoK 075fd22
nice
TingDaoK 8205aba
now it should work
TingDaoK 949c7e0
revert the ignore of the other tests
TingDaoK 38aa46c
trivial updates
TingDaoK 88ea9d0
Merge branch 'main' into http-canary
TingDaoK 9c60a0e
override on stream?
TingDaoK 87b79a7
consume the body
TingDaoK ce3edc9
remove the content length
TingDaoK de08df7
use 30s gap
TingDaoK 285c6d7
support non-tls uri
TingDaoK 45df768
use local server without body
TingDaoK f941879
non tls test
TingDaoK 79adafd
Revert "non tls test"
TingDaoK 4fcb93e
back to the server with body
TingDaoK a269139
send byte[] across jni
TingDaoK 47ed94c
update register type
TingDaoK 57ffd07
disable log
TingDaoK 4e7c9f1
make each connection 40 concurrent streams and 800 batch
TingDaoK f00e981
make sure the connections and streams are equal
TingDaoK 3e46f98
clean up a bit
TingDaoK f9813b6
typo
TingDaoK 699d702
use the new branch of http
TingDaoK db37f9a
update the branch
TingDaoK 623e167
make sure we error out when CRT result is smaller than netty
TingDaoK b357a9d
Merge branch 'main' into http-canary
TingDaoK 2fe9be5
Merge branch 'main' into http-canary
TingDaoK File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import Builder | ||
import sys | ||
import os | ||
|
||
|
||
class LocalhostCanary(Builder.Action): | ||
|
||
def run(self, env): | ||
env.shell.setenv('AWS_CRT_MEMORY_TRACING', '2') | ||
actions = [ | ||
"mvn install -DskipTests", | ||
"cd ./samples/HttpClientCanary && mvn install", | ||
"cd ./samples/HttpClientCanary && mvn exec:exec@netty", | ||
"cd ./samples/HttpClientCanary && mvn exec:exec@crt" | ||
] | ||
|
||
return Builder.Script(actions, name='aws-crt-java-test') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule aws-c-http
updated
12 files
+48 −1 | .github/workflows/ci.yml | |
+4 −0 | CMakeLists.txt | |
+29 −0 | bin/canary/CMakeLists.txt | |
+502 −0 | bin/canary/main.c | |
+2 −1 | builder.json | |
+3 −0 | include/aws/http/private/h2_connection.h | |
+51 −0 | integration-testing/http_client_canary.py | |
+1 −1 | integration-testing/http_client_test.py | |
+12 −6 | source/h2_connection.c | |
+1 −1 | tests/CMakeLists.txt | |
+0 −1 | tests/py_localhost/non_tls_server.py | |
+0 −9 | tests/test_h2_client.c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>com.canary</groupId> | ||
<artifactId>canary</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<maven.compiler.source>1.8</maven.compiler.source> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>software.amazon.awssdk.crt</groupId> | ||
<artifactId>aws-crt</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>software.amazon.awssdk</groupId> | ||
<artifactId>netty-nio-client</artifactId> | ||
<version>2.17.261</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.reactivex.rxjava2</groupId> | ||
<artifactId>rxjava</artifactId> | ||
<version>2.2.21</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<!-- Need to use exec not java see:http://mail.openjdk.java.net/pipermail/jmh-dev/2014-July/001192.html, https://stackoverflow.com/questions/15013651/using-maven-execexec-with-arguments --> | ||
<artifactId>exec-maven-plugin</artifactId> | ||
<version>1.6.0</version> | ||
<executions> | ||
<execution> | ||
<id>netty</id> | ||
<configuration> | ||
<executable>java</executable> | ||
<arguments> | ||
<argument>-classpath</argument> | ||
<classpath/> | ||
<argument>com.canary.SDKNettyClientCanary</argument> | ||
</arguments> | ||
</configuration> | ||
</execution> | ||
<execution> | ||
<id>crt</id> | ||
<configuration> | ||
<executable>java</executable> | ||
<arguments> | ||
<argument>-classpath</argument> | ||
<classpath/> | ||
<argument>com.canary.Http2StreamManagerCanary</argument> | ||
</arguments> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
66 changes: 66 additions & 0 deletions
66
samples/HttpClientCanary/src/main/java/com/canary/CanaryUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/** | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0. | ||
*/ | ||
|
||
package com.canary; | ||
|
||
import java.util.concurrent.*; | ||
import java.util.concurrent.atomic.AtomicBoolean; | ||
import java.util.concurrent.atomic.AtomicInteger; | ||
import java.util.ArrayList; | ||
|
||
public class CanaryUtils { | ||
private static final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(10); | ||
private static final AtomicInteger numDataCollected = new AtomicInteger(0); | ||
|
||
public static ScheduledExecutorService createDataCollector(int warmupLoops, int loops, long timerSecs, | ||
AtomicInteger opts, AtomicBoolean done, | ||
ArrayList<Double> warmupResults, ArrayList<Double> results) { | ||
ScheduledFuture<?> task = scheduler.scheduleAtFixedRate(new Runnable() { | ||
@Override | ||
public void run() { | ||
int numCollected = numDataCollected.incrementAndGet(); | ||
int collectedOpts = opts.getAndSet(0); | ||
double result = (double)collectedOpts/(double)timerSecs; | ||
if (numCollected <= warmupLoops) { | ||
System.out.println("warm up: " + result); | ||
warmupResults.add(result); | ||
return; | ||
} | ||
if (numCollected > loops + warmupLoops) { | ||
done.set(true); | ||
return; | ||
} | ||
System.out.println("result: " + result); | ||
results.add(result); | ||
} | ||
}, timerSecs, timerSecs, TimeUnit.SECONDS); | ||
return scheduler; | ||
} | ||
|
||
public static double calculateAverage(ArrayList<Double> list) { | ||
return list.stream().mapToDouble(d -> d).average().orElse(0.0); | ||
} | ||
|
||
public static double calculateSTD(ArrayList<Double> list) { | ||
double avg = calculateAverage(list); | ||
|
||
double variance = 0; | ||
for (int i = 0; i < list.size(); i++) { | ||
variance += Math.pow(list.get(i) - avg, 2); | ||
} | ||
variance /= (list.size()-1); | ||
return Math.sqrt(variance); | ||
} | ||
|
||
/* Return avg of the list and print out the avg and std */ | ||
public static double printResult(ArrayList<Double> list) { | ||
double avg = calculateAverage(list); | ||
double std = calculateSTD(list); | ||
System.out.println("Result collected has: " + list.size()); | ||
System.out.println("avg of all samples: " + avg); | ||
System.out.println("Standard deviation of all samples: " + std); | ||
return avg; | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
samples/HttpClientCanary/src/main/java/com/canary/EmptyPublisher.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.canary; | ||
|
||
import java.nio.ByteBuffer; | ||
import java.util.Optional; | ||
import org.reactivestreams.Subscriber; | ||
import org.reactivestreams.Subscription; | ||
import software.amazon.awssdk.http.async.SdkHttpContentPublisher; | ||
|
||
public class EmptyPublisher implements SdkHttpContentPublisher { | ||
@Override | ||
public void subscribe(Subscriber<? super ByteBuffer> subscriber) { | ||
subscriber.onSubscribe(new EmptySubscription(subscriber)); | ||
} | ||
|
||
@Override | ||
public Optional<Long> contentLength() { | ||
return Optional.of(0L); | ||
} | ||
|
||
private static class EmptySubscription implements Subscription { | ||
private final Subscriber subscriber; | ||
private volatile boolean done; | ||
|
||
EmptySubscription(Subscriber subscriber) { | ||
this.subscriber = subscriber; | ||
} | ||
|
||
@Override | ||
public void request(long l) { | ||
if (!done) { | ||
done = true; | ||
if (l <= 0) { | ||
this.subscriber.onError(new IllegalArgumentException("Demand must be positive")); | ||
} else { | ||
this.subscriber.onComplete(); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public void cancel() { | ||
done = true; | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This version doesn't work for me on an M1. I get the following error
I changed it to 0.19.3 and it is working now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, you need
mvn install on the root directory
first.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, that seems like weird...
It's search for
x86_64
on your arm machine.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What
JAVA_HOME
you set? Do you have a x86 java on you machine?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My Java Home is /Users/waqarak/Library/Java/JavaVirtualMachines/corretto-11.0.16/Contents/Home. I did run mvn install on the root directory.