Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions frameworks/cardigan/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"latency-1m", "latency-10k",
"pipelined",
"limited-conn",
"8gbit",
"json-tls",
"baseline-h2",
"static-h2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.lang.foreign.Arena;
import java.lang.foreign.MemorySegment;
import java.lang.foreign.ValueLayout;
import java.util.Arrays;

/** The small arithmetic endpoints shared by the HttpArena transports. */
public final class HttpArenaController {
Expand Down Expand Up @@ -46,6 +47,48 @@ public Response baseline2(
return Response.text((long) a + b);
}

@Post("/echo")
public Response echo(RequestBody body) {
return Response.bytes(
"application/octet-stream",
readBody(body));
}

private static byte[] readBody(RequestBody body) {
long declaredLength = body.length();
if (declaredLength > Integer.MAX_VALUE) {
throw new IllegalArgumentException("echo body is too large");
}

int initialCapacity = declaredLength >= 0
? (int) declaredLength
: 16 * 1024;
byte[] bytes = new byte[initialCapacity];
int length = 0;
while (declaredLength < 0 || length < initialCapacity) {
if (length == bytes.length) {
int nextCapacity = Math.max(1, bytes.length << 1);
if (nextCapacity <= bytes.length) {
throw new IllegalArgumentException("echo body is too large");
}
bytes = Arrays.copyOf(bytes, nextCapacity);
}
int read = body.read(
MemorySegment.ofArray(bytes).asSlice(
length, bytes.length - length));
if (read < 0) {
break;
}
length += read;
}

if (declaredLength >= 0 && length != initialCapacity) {
throw new IllegalArgumentException(
"echo body ended before its declared length");
}
return length == bytes.length ? bytes : Arrays.copyOf(bytes, length);
}

private static long readLong(RequestBody body, MemorySegment scratch) {
long value = 0;
boolean negative = false;
Expand Down
25 changes: 25 additions & 0 deletions site/data/results/cardigan.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,31 @@
{
"framework": "cardigan",
"results": {
"8gbit-512": {
"framework": "cardigan",
"language": "Java",
"rps": 49382,
"avg_latency": "115.1us",
"p99_latency": "622.0us",
"cpu": "289.3%",
"memory": "1.0GiB",
"connections": 512,
"threads": 64,
"duration": "5s",
"pipeline": 1,
"bandwidth": "509.72MB/s",
"input_bw": "482.25MB/s",
"reconnects": 0,
"status_2xx": 246990,
"status_3xx": 0,
"status_4xx": 0,
"status_5xx": 0,
"cpu_usec": 14999296,
"cpu_per_req_us": 60.7284,
"target_rate": 50000,
"rate_ratio": 0.9876,
"p99_9_latency": "4658.0us"
},
"baseline-4096": {
"framework": "cardigan",
"language": "Java",
Expand Down
Loading