Skip to content

Commit

Permalink
[Java] disable async compilation for graalvm (#1222)
Browse files Browse the repository at this point in the history
* disable async compilation for graalvm

* add asyncCompilationEnabled disable option doc.

* lint code
  • Loading branch information
chaokunyang authored Dec 10, 2023
1 parent a275c68 commit f47e95e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions docs/guide/graalvm_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ Another benefit using fury is that you don't have to configure [reflection json]
very tedious, cumbersome and inconvenient. When using fury, you just need to invoke
`io.fury.Fury.register(Class<?>, boolean)` for every type you want to serialize.

Note that Fury `asyncCompilationEnabled` option will be disabled automatically for graalvm native image since graalvm
native image doesn't support JIT at the image run time.

## Not thread-safe Fury
Example:
```java
Expand Down
8 changes: 8 additions & 0 deletions java/fury-core/src/main/java/io/fury/config/FuryBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import io.fury.serializer.Serializer;
import io.fury.serializer.TimeSerializers;
import io.fury.serializer.collection.GuavaCollectionSerializers;
import io.fury.util.GraalvmSupport;
import io.fury.util.LoggerFactory;
import io.fury.util.Platform;
import java.util.Objects;
Expand Down Expand Up @@ -258,6 +259,9 @@ public FuryBuilder withCodegen(boolean codeGen) {
* serialization first and switch to jit serialization after async serializer jit for a class \ is
* finished.
*
* <p>This option will be disabled automatically for graalvm native image since graalvm native
* image doesn't support JIT at the image run time.
*
* @see Config#isAsyncCompilationEnabled()
*/
public FuryBuilder withAsyncCompilation(boolean asyncCompilation) {
Expand Down Expand Up @@ -305,6 +309,10 @@ private void finish() {
if (suppressClassRegistrationWarnings == null) {
suppressClassRegistrationWarnings = !requireClassRegistration;
}
if (GraalvmSupport.IN_GRAALVM_NATIVE_IMAGE && asyncCompilationEnabled) {
LOG.info("Use sync compilation for graalvm native image since it doesn't support JIT.");
asyncCompilationEnabled = false;
}
}

/**
Expand Down

0 comments on commit f47e95e

Please sign in to comment.