Skip to content

add AOT & native image support#638

Merged
reta merged 4 commits intoopensearch-project:mainfrom
rursprung:add-aot-support
Apr 17, 2026
Merged

add AOT & native image support#638
reta merged 4 commits intoopensearch-project:mainfrom
rursprung:add-aot-support

Conversation

@rursprung
Copy link
Copy Markdown
Contributor

@rursprung rursprung commented Mar 26, 2026

this registers the necessary hints for Ahead-of-Time Processing to support both AOT and GraalVM Native Image usage. it also modifies one example application so that it can - optionally - be run as a native image to show that it works. this is also used in CI to test that it still builds.

on its own this will fail since by using AOT we automatically also pull in the AOT hints registered in spring-data-elasticsearch which in turn currently unconditionally registers hints for the Elasticsearch Client (ELC) which we however exclude as a transient dependency. thus a PR has been raised to make this optional: spring-projects/spring-data-elasticsearch#3267 this will have to be merged & released first for this PR to work.

i have however verified things locally (though admittedly on the previous major release since i only had GraalVM 21 at hand and SB 4.x requires GraalVM 25).

Issues Resolved

resolves #441

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Comment thread spring-data-opensearch-examples/spring-boot-java-client-gradle/build.gradle.kts Outdated
@rursprung
Copy link
Copy Markdown
Contributor Author

good news! spring-projects/spring-data-elasticsearch#3267 got merged and cherry-picked to their 6.0.x branch (spring-projects/spring-data-elasticsearch@6b3646b) 🥳
i'll update this PR here once the new release of spring-data-elasticsearch is out and we can use it here

Comment thread .github/workflows/main_and_pr_workflow.yml
this registers the necessary hints for [Ahead-of-Time Processing] to
support both AOT and [GraalVM Native Image] usage. it also modifies one
example application so that it can - optionally - be run as a native
image to show that it works. this is also used in CI to test that it
still builds.

on its own this will fail since by using AOT we automatically also pull
in the AOT hints registered in `spring-data-elasticsearch` which in turn
currently unconditionally registers hints for the Elasticsearch Client
(ELC) which we however exclude as a transient dependency. thus a PR has
been raised to make this optional: spring-projects/spring-data-elasticsearch#3267
this has been merged in `spring-data-elasticsearch` on `main` (v6.1.x),
`6.0.x` and `5.5.x` and been released as part of v5.5.11 and v6.0.5.

`ElasticsearchClientAutoConfiguration` also needs to be excluded in the
`MarketplaceApplication` since otherwise two `JacksonJsonpMapper` beans
will be present and the application will fail to start in the
`processAot` phase.

`@since` is set to 2.0.6 since this will be cherry-picked also to that
release, offering AOT & native image support on Spring Boot 3.5.x, 4.0.x
and 4.1.x.

resolves opensearch-project#411

[Ahead-of-Time Processing]: https://docs.spring.io/spring-boot/reference/packaging/aot.html
[GraalVM Native Image]: https://docs.spring.io/spring-boot/reference/packaging/native-image/index.html

Signed-off-by: Ralph Ursprung <Ralph.Ursprung@avaloq.com>
@rursprung rursprung marked this pull request as ready for review April 17, 2026 14:46
@reta reta force-pushed the add-aot-support branch from 371a64f to 4148542 Compare April 17, 2026 15:08
Signed-off-by: Andriy Redko <drreta@gmail.com>
@reta reta force-pushed the add-aot-support branch from 4148542 to 6226e7c Compare April 17, 2026 15:27
@rursprung
Copy link
Copy Markdown
Contributor Author

btw, here are performance numbers using oha for the test application:

using AOT & native image:

$ oha 'http://localhost:8080/marketplace/search?name=pillow&price=35.0'
Summary:
  Success rate: 100.00%
  Total:        1740.3914 ms
  Slowest:      648.1584 ms
  Fastest:      319.3822 ms
  Average:      411.4771 ms
  Requests/sec: 114.9167

  Total data:   71.68 KiB
  Size/request: 367 B
  Size/sec:     41.19 KiB

Response time histogram:
  319.382 ms [1]  |
  352.260 ms [91] |■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  385.137 ms [8]  |■■
  418.015 ms [9]  |■■■
  450.893 ms [35] |■■■■■■■■■■■■
  483.770 ms [21] |■■■■■■■
  516.648 ms [6]  |■■
  549.526 ms [8]  |■■
  582.403 ms [6]  |■■
  615.281 ms [6]  |■■
  648.158 ms [9]  |■■■

Response time distribution:
  10.00% in 326.4643 ms
  25.00% in 342.9262 ms
  50.00% in 401.9459 ms
  75.00% in 456.0001 ms
  90.00% in 560.9410 ms
  95.00% in 615.1456 ms
  99.00% in 645.6026 ms
  99.90% in 648.1584 ms
  99.99% in 648.1584 ms


Details (average, fastest, slowest):
  DNS+dialup:   19.9586 ms, 3.0094 ms, 32.3918 ms
  DNS-lookup:   0.1231 ms, 0.0041 ms, 0.8391 ms

Status code distribution:
  [200] 200 responses

normal JVM:

$ oha 'http://localhost:8080/marketplace/search?name=pillow&price=35.0'
Summary:
  Success rate: 100.00%
  Total:        3.1196 sec
  Slowest:      1.5639 sec
  Fastest:      0.3289 sec
  Average:      0.7488 sec
  Requests/sec: 64.1105

  Total data:   71.68 KiB
  Size/request: 367 B
  Size/sec:     22.98 KiB

Response time histogram:
  0.329 sec [1]  |
  0.452 sec [93] |■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
  0.576 sec [28] |■■■■■■■■■
  0.699 sec [9]  |■■■
  0.823 sec [19] |■■■■■■
  0.946 sec [0]  |
  1.070 sec [0]  |
  1.193 sec [0]  |
  1.317 sec [0]  |
  1.440 sec [0]  |
  1.564 sec [50] |■■■■■■■■■■■■■■■■■

Response time distribution:
  10.00% in 0.3678 sec
  25.00% in 0.4083 sec
  50.00% in 0.4900 sec
  75.00% in 1.5617 sec
  90.00% in 1.5629 sec
  95.00% in 1.5631 sec
  99.00% in 1.5636 sec
  99.90% in 1.5639 sec
  99.99% in 1.5639 sec


Details (average, fastest, slowest):
  DNS+dialup:   0.0146 sec, 0.0031 sec, 0.0211 sec
  DNS-lookup:   0.0000 sec, 0.0000 sec, 0.0002 sec

Status code distribution:
  [200] 200 responses

the speedup is significant (factor 2)

Comment thread settings.gradle.kts Outdated
Comment thread settings.gradle.kts Outdated
reta added 2 commits April 17, 2026 11:53
Signed-off-by: Andriy Redko <drreta@gmail.com>
Signed-off-by: Andriy Redko <drreta@gmail.com>
@reta reta added v3.0.5 and removed v3.1.0 labels Apr 17, 2026
@reta reta merged commit 3d76776 into opensearch-project:main Apr 17, 2026
14 checks passed
@rursprung rursprung deleted the add-aot-support branch April 17, 2026 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] support for Spring AOT

2 participants