fury
fury copied to clipboard
Big Bean compile take too long time
Search before asking
- [X] I had searched in the issues and found no similar issues.
Version
jdk: 17 fury: 0.4.1
Component(s)
Java
Minimal reproduce step
Create a bean containing 350 fields. The first serialization takes nearly 40 seconds.
What did you expect to see?
Reduce time, or can be pre-compiled
What did you see instead?
Reduce time, or can be pre-compiled
Anything Else?
No response
Are you willing to submit a PR?
- [ ] I'm willing to submit a PR!
You can invoke Fury to generate serializer code to java files first, then compile it with your project together:
BaseObjectCodecBuilder codecBuilder = new ObjectCodecBuilder(cls, fury);
String code = codecBuilder.genCode();
Files.write(new File(codecBuilder.codecQualifiedClassName(cls).replace(".", "/") + ".java").toPath(),
code.getBytes(StandardCharsets.UTF_8));
Async compilation can be used for such cases too, it will compile generate serializer in background, and the serialization will use intepreter serializer before compilation finishes:
Fury fury=Fury.builder()
.withLanguage(Language.JAVA)
// enable reference tracking for shared/circular reference.
// Disable it will have better performance if no duplicate reference.
.withRefTracking(false)
.withCompatibleMode(CompatibleMode.SCHEMA_CONSISTENT)
// enable type forward/backward compatibility
// disable it for small size and better performance.
// .withCompatibleMode(CompatibleMode.COMPATIBLE)
// enable async multi-threaded compilation.
.withAsyncCompilation(true)
.build();