chaokunyang commented on code in PR #2553: URL: https://github.com/apache/fory/pull/2553#discussion_r2322585562
########## go/README.md: ########## @@ -2,9 +2,149 @@ Fory is a blazingly fast multi-language serialization framework powered by just-in-time compilation and zero-copy. -Currently, Fory Go is implemented using reflection. In the future, we plan to implement a static code generator -to generate serializer code ahead to speed up serialization, or implement a JIT framework which generate ASM -instructions to speed up serialization. +Currently, Fory Go is implemented using reflection. We have also implemented a static code generator to generate serializer code ahead of time to speed up serialization. + +## Fory Go Codegen (optional) + +This repository includes an optional ahead-of-time (AOT) code generator for Fory. The runtime reflection-based path continues to work; codegen exists to provide additional performance, type safety and zero-reflection overhead for hot paths. You can adopt it incrementally, per package or per file. + +### Why codegen (rationale) + +- Faster (no reflection on the hot path) +- Type-safe serialization/deserialization with predictable layouts +- Smaller GC pressure and fewer allocations +- Compile-time guards to detect stale generated code when struct definitions change + +Note: Code generation is not mandatory. If you prefer simple workflows, you can keep using the reflection-based API. + +### Install the generator + +The generator binary is `fory`. + +- Go 1.16+ (recommended): + +```bash +go install github.com/apache/fory/go/fory/cmd/fory@latest +``` + +- Go 1.13–1.15: Review Comment: ```suggestion - Go 1.13+ ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
