Re:Fury: 170x faster than JDK, blazing fast serialization by...
by aardvark179 on Sunday October 08, 2023 @04:35PM
(#37814190)
The danger with generating source code is that you now depend on source rules which may have changed, never applied to your source language, or are made more complicated by class loading refs. Iād definitely go for byte code generation, and possibly using constant dynamic to handle any really tricky constants, over source code any day.
[ Parent
| on HN ]
Re:Fury: 170x faster than JDK, blazing fast serialization by...
by SpaghettiCthulu on Sunday October 08, 2023 @10:06PM
(#37816219)
I would go for `MethodHandle`s and lambda metafactory over bytecode where possible. Much easier to avoid and debug bugs in the generation (better errors than those provided by Hotspot's verifier), and avoids needing to worry about constant dynamic at all. Of course, once you need to implement more than one method, you can no longer just use lambda metafactory.
A while back I actually implemented some utilities for generating classes at runtime and "linking" constants into them using constant dynamic. One day I might clean it up and release it as a library.
Re:Fury: 170x faster than JDK, blazing fast serialization by...
by chaokunyang on Sunday October 08, 2023 @11:22PM
(#37816602)
Good point, I used `lambda metafactory` too in fury, but only for some `constructor/getters`. I implements some Function utils to generate lambda function, see https://github.com/alipay/fury/blob/main/java/fury-core/src/...
I'm not sure whether `MethodHandle` can generate the most complicated code, since the serialization logic here are more complicated even than the manual written code.
Re:Fury: 170x faster than JDK, blazing fast serialization by...
by chaokunyang on Sunday October 08, 2023 @11:22PM
(#37816606)
Looking forward to your library
Re:Fury: 170x faster than JDK, blazing fast serialization by...
by chaokunyang on Sunday October 08, 2023 @11:27PM
(#37816634)
We used https://github.com/janino-compiler/janino to compile the generated code at runtime It's stable and the compiler used by spark/flink.
Janino can generated the bytecode for fury generated java code.
I must agree that generating bytecode directly has it's advantages, the abstraction is more low-level, thus more flexible, except more complicated for developing.