Skip to content

FFM Test Branch#985

Draft
sbSteveK wants to merge 4 commits intomainfrom
ffm-java22
Draft

FFM Test Branch#985
sbSteveK wants to merge 4 commits intomainfrom
ffm-java22

Conversation

@sbSteveK
Copy link
Copy Markdown
Contributor

@sbSteveK sbSteveK commented May 8, 2026

FFM testing branch.

DO NOT MERGE

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

…wnload

Adds a useFFM flag to S3MetaRequestOptions that activates zero-copy
callbacks on the two performance-critical paths:

Download (s_on_s3_meta_request_body_callback):
- JNI path: allocates a byte[] and copies every downloaded chunk into it
- FFM path: passes the raw native pointer + length as jlong primitives;
  Java wraps it as a MemorySegment (zero-copy) via onResponseBodyFFM()

Upload (s_aws_input_stream_read):
- JNI path: creates a DirectByteBuffer wrapper object per part, reads
  back position() via a second JNI call
- FFM path: passes raw pointer + capacity as jlong primitives; Java
  writes directly into native memory and returns bytes-written as int

Java-side changes:
- S3MetaRequestOptions: add withUseFFM(boolean) / getUseFFM()
- S3Client: pass useFFM to native s3ClientMakeMetaRequest()
- S3MetaRequestResponseHandler: add onResponseBody(MemorySegment,...) overload
- S3MetaRequestResponseHandlerNativeAdapter: add onResponseBodyFFM(long,long,long)
- HttpRequestBodyStream: add sendRequestBody(long address, long length) -> int

Native-side changes:
- java_class_ids.h/c: register send_outgoing_body_ffm (JJ)I and
  onResponseBodyFFM (JJJ)I method IDs
- s3_client.c: add use_ffm to callback struct; branch in body callback
- http_request_utils.h/c: add use_ffm to stream impl; branch in read fn;
  propagate use_ffm through aws_apply_java_http_request_changes_to_native_request
@sbSteveK sbSteveK changed the title Add FFM (Foreign Function & Memory) hot-path support for S3 upload/do… FFM Test Branch May 8, 2026
sbSteveK and others added 3 commits May 8, 2026 09:08
Three callers were missing the new use_ffm parameter:
- aws_signing.c: aws_input_stream_new_from_java_http_request_body_stream()
  -> add false (signing path always uses JNI)
- mqtt_connection.c: aws_apply_java_http_request_changes_to_native_request()
  -> add false (MQTT path always uses JNI)
- mqtt5_client.c: aws_apply_java_http_request_changes_to_native_request()
  -> add false (MQTT5 path always uses JNI)

Also fix the unused-parameter warning in http_request_utils.c:
- aws_apply_java_http_request_changes_to_native_request() now passes
  use_ffm through to aws_input_stream_new_from_java_http_request_body_stream()
  instead of hardcoding false, making the parameter actually used.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant