Skip to content

Commit 55218a5

Browse files
committed
CopyMode enum must be public
1 parent b0702e1 commit 55218a5

3 files changed

Lines changed: 31 additions & 30 deletions

File tree

runners/s3-benchrunner-java/src/main/java/com/example/s3benchrunner/Main.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import com.example.s3benchrunner.crtjava.CRTJavaBenchmarkRunner;
77
import com.example.s3benchrunner.ffmjava.FFMJavaBenchmarkRunner;
8-
import com.example.s3benchrunner.ffmjava.FFMJavaTask;
98
import com.example.s3benchrunner.sdkjava.SDKJavaBenchmarkRunner;
109

1110
public class Main {
@@ -75,11 +74,11 @@ public static void main(String[] args) throws Exception {
7574
// FFM with explicit copy to GC-managed byte[] — simulates an app that needs
7675
// a Java-owned copy of downloaded data (same destination as JNI, but via FFM)
7776
case "ffm-java-copy-heap" -> new FFMJavaBenchmarkRunner(config, bucket, region, targetThroughputGbps,
78-
FFMJavaTask.CopyMode.HEAP_COPY);
77+
FFMJavaBenchmarkRunner.CopyMode.HEAP_COPY);
7978
// FFM with explicit copy to pre-allocated off-heap MemorySegment — simulates
8079
// an app that needs an owned copy but wants to avoid GC pressure entirely
8180
case "ffm-java-copy-offheap" -> new FFMJavaBenchmarkRunner(config, bucket, region, targetThroughputGbps,
82-
FFMJavaTask.CopyMode.OFFHEAP_COPY);
81+
FFMJavaBenchmarkRunner.CopyMode.OFFHEAP_COPY);
8382
case "sdk-java-client-crt" ->
8483
new SDKJavaBenchmarkRunner(config, bucket, region, targetThroughputGbps, false, true);
8584
case "sdk-java-tm-crt" ->

runners/s3-benchrunner-java/src/main/java/com/example/s3benchrunner/ffmjava/FFMJavaBenchmarkRunner.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,21 @@
3131
*/
3232
public class FFMJavaBenchmarkRunner extends BenchmarkRunner {
3333

34+
/**
35+
* Controls what happens with downloaded data in the FFM response body callback.
36+
* Exposed as a public nested enum so that {@code Main.java} (in a different
37+
* package) can reference it without needing access to the package-private
38+
* {@code FFMJavaTask} class.
39+
*/
40+
public enum CopyMode {
41+
/** Discard data immediately — zero-copy, no allocation. */
42+
NONE,
43+
/** Copy into a GC-managed {@code byte[]} on every callback. */
44+
HEAP_COPY,
45+
/** Copy into a pre-allocated off-heap {@link java.lang.foreign.MemorySegment}. */
46+
OFFHEAP_COPY,
47+
}
48+
3449
// CRT boilerplate
3550
EventLoopGroup eventLoopGroup;
3651
HostResolver hostResolver;
@@ -43,14 +58,14 @@ public class FFMJavaBenchmarkRunner extends BenchmarkRunner {
4358
String endpoint;
4459

4560
// Controls what happens with downloaded data in the response body callback
46-
FFMJavaTask.CopyMode copyMode;
61+
CopyMode copyMode;
4762

4863
public FFMJavaBenchmarkRunner(BenchmarkConfig config, String bucket, String region, double targetThroughputGbps) {
49-
this(config, bucket, region, targetThroughputGbps, FFMJavaTask.CopyMode.NONE);
64+
this(config, bucket, region, targetThroughputGbps, CopyMode.NONE);
5065
}
5166

5267
public FFMJavaBenchmarkRunner(BenchmarkConfig config, String bucket, String region, double targetThroughputGbps,
53-
FFMJavaTask.CopyMode copyMode) {
68+
CopyMode copyMode) {
5469

5570
super(config, bucket, region);
5671

runners/s3-benchrunner-java/src/main/java/com/example/s3benchrunner/ffmjava/FFMJavaTask.java

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -32,38 +32,25 @@
3232
* object allocation).</li>
3333
* </ul>
3434
* <p>
35-
* The {@link CopyMode} controls what happens with downloaded data in the
36-
* response body callback:
35+
* The {@link FFMJavaBenchmarkRunner.CopyMode} controls what happens with
36+
* downloaded data in the response body callback:
3737
* <ul>
38-
* <li>{@link CopyMode#NONE} — data is discarded (zero-copy, benchmark
39-
* measures pure download throughput with no data processing)</li>
40-
* <li>{@link CopyMode#HEAP_COPY} — data is copied into a GC-managed
41-
* {@code byte[]} (simulates an application that needs a Java-owned copy)</li>
42-
* <li>{@link CopyMode#OFFHEAP_COPY} — data is copied into a pre-allocated
43-
* off-heap {@link MemorySegment} (simulates an application that needs an
44-
* owned copy but wants to avoid GC pressure)</li>
38+
* <li>{@link FFMJavaBenchmarkRunner.CopyMode#NONE} — data is discarded
39+
* (zero-copy, benchmark measures pure download throughput)</li>
40+
* <li>{@link FFMJavaBenchmarkRunner.CopyMode#HEAP_COPY} — data is copied
41+
* into a GC-managed {@code byte[]}</li>
42+
* <li>{@link FFMJavaBenchmarkRunner.CopyMode#OFFHEAP_COPY} — data is copied
43+
* into a pre-allocated off-heap {@link MemorySegment}</li>
4544
* </ul>
4645
*/
4746
class FFMJavaTask implements S3MetaRequestResponseHandler {
4847

49-
/**
50-
* Controls what happens with downloaded data in the response body callback.
51-
*/
52-
enum CopyMode {
53-
/** Discard data immediately — zero-copy, no allocation. */
54-
NONE,
55-
/** Copy into a GC-managed {@code byte[]} on every callback. */
56-
HEAP_COPY,
57-
/** Copy into a pre-allocated off-heap {@link MemorySegment}. */
58-
OFFHEAP_COPY,
59-
}
60-
6148
FFMJavaBenchmarkRunner runner;
6249
int taskI;
6350
TaskConfig config;
6451
S3MetaRequest metaRequest;
6552
CompletableFuture<Void> doneFuture;
66-
final CopyMode copyMode;
53+
final FFMJavaBenchmarkRunner.CopyMode copyMode;
6754

6855
/**
6956
* Pre-allocated off-heap buffer for {@link CopyMode#OFFHEAP_COPY}.
@@ -73,15 +60,15 @@ enum CopyMode {
7360
private final MemorySegment offheapCopyBuffer;
7461
private static final long OFFHEAP_BUFFER_SIZE = 8L * 1024 * 1024; // 8 MiB
7562

76-
FFMJavaTask(FFMJavaBenchmarkRunner runner, int taskI, CopyMode copyMode) {
63+
FFMJavaTask(FFMJavaBenchmarkRunner runner, int taskI, FFMJavaBenchmarkRunner.CopyMode copyMode) {
7764
this.runner = runner;
7865
this.taskI = taskI;
7966
this.config = runner.config.tasks.get(taskI);
8067
this.copyMode = copyMode;
8168
doneFuture = new CompletableFuture<Void>();
8269

8370
// Pre-allocate off-heap buffer if needed
84-
if (copyMode == CopyMode.OFFHEAP_COPY) {
71+
if (copyMode == FFMJavaBenchmarkRunner.CopyMode.OFFHEAP_COPY) {
8572
offheapCopyBuffer = Arena.ofAuto().allocate(OFFHEAP_BUFFER_SIZE);
8673
} else {
8774
offheapCopyBuffer = null;

0 commit comments

Comments
 (0)