Apache Fory 团队很高兴宣布 0.17.0 版本正式发布。这是一个重要版本,包含来自 19 位贡献者的 71 个 PR。请访问 Install 页面 获取各平台安装方式。
JavaScript/NodeJS Serialization:首次发布
Apache Fory 0.17.0 首次正式提供 JavaScript/NodeJS 文档、基准测试覆盖,以及对 TypeScript 友好的 IDL 代码生成支持。JavaScript 运行时面向现代 Node.js 服务和 TypeScript 代码库构建,同时保留了 Fory 的跨语言对象模型、Schema 驱动 API,以及可选的引用跟踪能力。
关键能力:
- 面向 Node.js 中 JavaScript 和 TypeScript 对象的高性能序列化
- 支持与 Java、Python、Go、Rust、C#、Swift 和 Dart 的跨语言兼容
- 通过
Type.*builder 与 TypeScript decorator 提供 Schema 驱动 API - 可选的引用跟踪,用于处理共享引用和循环引用对象图
- 用于 Schema 演进的兼容模式
- 可配置的深度、二进制大小和集合大小护栏
- 在 Fory IDL/compiler 工作流中支持 JavaScript/TypeScript target
- 为 Node.js 20+ 提供可选的
@apache-fory/hps快速字符串路径
快速开始
import Fory, { Type } from "@apache-fory/core";
const userType = Type.struct(
{ typeName: "example.user" },
{
id: Type.int64(),
name: Type.string(),
age: Type.int32(),
},
);
const fory = new Fory();
const { serialize, deserialize } = fory.register(userType);
const bytes = serialize({
id: 1n,
name: "Alice",
age: 30,
});
const user = deserialize(bytes);
console.log(user);
- JavaScript 指南: https://fory.apache.org/docs/guide/javascript/
- Compiler 文档: https://fory.apache.org/docs/compiler/
JavaScript 基准测试
以下是代表性数据结构上的吞吐结果(ops/sec,越高越好),用于比较 Fory、Protocol Buffers 与 JSON。
| Datatype | Operation | Fory TPS | Protobuf TPS | JSON TPS | Fastest |
|---|---|---|---|---|---|
| Struct | Serialize | 8,453,950 | 1,903,706 | 3,058,232 | fory |
| Struct | Deserialize | 9,705,287 | 8,233,664 | 3,860,538 | fory |
| Sample | Serialize | 1,498,391 | 422,620 | 744,790 | fory |
| Sample | Deserialize | 1,918,162 | 819,010 | 762,048 | fory |
| MediaContent | Serialize | 1,293,157 | 729,497 | 1,299,908 | json |
| MediaContent | Deserialize | 1,638,086 | 1,209,140 | 921,191 | fory |
| StructList | Serialize | 3,928,325 | 495,648 | 891,810 | fory |
| StructList | Deserialize | 3,264,827 | 1,529,744 | 986,144 | fory |
| SampleList | Serialize | 355,581 | 92,741 | 163,120 | fory |
| SampleList | Deserialize | 424,916 | 163,253 | 162,520 | fory |
| MediaContentList | Serialize | 286,053 | 148,977 | 282,445 | fory |
| MediaContentList | Deserialize | 376,826 | 244,622 | 190,155 | fory |
序列化数据大小(bytes):
| Datatype | Fory | Protobuf | JSON |
|---|---|---|---|
| Struct | 58 | 61 | 103 |
| Sample | 446 | 377 | 724 |
| MediaContent | 391 | 307 | 596 |
| StructList | 184 | 315 | 537 |
| SampleList | 1980 | 1900 | 3642 |
| MediaContentList | 1665 | 1550 | 3009 |
详细基准数据请参见: https://github.com/apache/fory/tree/v0.17.0/benchmarks/javascript
Dart Serialization:首次发布
Apache Fory 0.17.0 也正式带来了 Dart serialization 的首次发布,提供官方文档、基准测试覆盖、重构后的运行时,以及 Dart IDL 支持。Dart 实现重点关注生成式 serializer、稳定的跨语言类型标识、Schema 演进,以及面向服务工作负载的可预测 API。
关键能力:
- 使用生成代码而非反射实现高性能 Dart serialization
- 支持与 Java、Python、Go、Rust、C#、Swift 和 JavaScript 的跨语言兼容
- 提供
@ForyStruct和@ForyField注解,并结合build_runner进行代码生成 - 用于跨版本 Schema 演进的兼容模式
- 可选的引用跟踪,用于处理共享引用和循环引用对象图
- 为高级或自定义类型提供手动
Serializer<T>扩展点 - 在 Fory IDL/compiler 工作流中支持 Dart target
快速开始
import 'package:fory/fory.dart';
part 'person.fory.dart';
enum Color {
red,
blue,
}
()
class Person {
Person();
String name = '';
Int32 age = Int32(0);
Color favoriteColor = Color.red;
}
void main() {
final fory = Fory();
PersonFory.register(
fory,
Color,
namespace: 'example',
typeName: 'Color',
);
PersonFory.register(
fory,
Person,
namespace: 'example',
typeName: 'Person',
);
final bytes = fory.serialize(Person()
..name = 'Ada'
..age = Int32(36)
..favoriteColor = Color.blue);
final roundTrip = fory.deserialize<Person>(bytes);
print(roundTrip.name);
}
- Dart 指南: https://fory.apache.org/docs/guide/dart/
- Compiler 文档: https://fory.apache.org/docs/compiler/
Dart 基准测试
以下是代表性数据结构上的吞吐结果(ops/sec,越高越好),用于比较 Fory 与 Protocol Buffers。
| Datatype | Operation | Fory TPS | Protobuf TPS | Fastest |
|---|---|---|---|---|
| Struct | Serialize | 3,989,432 | 1,884,653 | fory (2.12x) |
| Struct | Deserialize | 5,828,197 | 4,199,680 | fory (1.39x) |
| Sample | Serialize | 1,649,722 | 500,167 | fory (3.30x) |
| Sample | Deserialize | 2,060,113 | 785,109 | fory (2.62x) |
| MediaContent | Serialize | 800,876 | 391,235 | fory (2.05x) |
| MediaContent | Deserialize | 1,315,115 | 683,533 | fory (1.92x) |
| StructList | Serialize | 1,456,396 | 367,506 | fory (3.96x) |
| StructList | Deserialize | 1,921,006 | 645,958 | fory (2.97x) |
| SampleList | Serialize | 411,144 | 48,508 | fory (8.48x) |
| SampleList | Deserialize | 464,273 | 103,558 | fory (4.48x) |
| MediaContentList | Serialize | 186,870 | 77,029 | fory (2.43x) |
| MediaContentList | Deserialize | 330,293 | 128,215 | fory (2.58x) |
序列化数据大小(bytes):
| Datatype | Fory | Protobuf |
|---|---|---|
| Struct | 58 | 61 |
| Sample | 446 | 377 |
| MediaContent | 365 | 307 |
| StructList | 184 | 315 |
| SampleList | 1980 | 1900 |
| MediaContentList | 1535 | 1550 |
详细基准数据请参见: https://github.com/apache/fory/tree/v0.17.0/benchmarks/dart
发布亮点
- refactor(java): 重构 fory java serialization API,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3537
- refactor(python): 重构 python serialization API,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3543
- feat(java): 通过在 Fory 实例间共享来降低 java serializer 内存占用,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3546
- feat(java): 从 fory java 中移除 guava 依赖,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3557
- refactor(dart): 全新的 dart 实现,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3551
功能特性
- refactor(javascript): 将 apache-fory/fory 重命名为 apache-fory/core,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3489
- feat(ci): 为 bazel 下载增加重试机制,作者 @BaldDemian,见 https://github.com/apache/fory/pull/3492
- feat(go): 增加可配置的大小护栏,作者 @ayush00git,见 https://github.com/apache/fory/pull/3475
- refactor(ci): 使用 setup-bazel 安装 Bazel,作者 @BaldDemian,见 https://github.com/apache/fory/pull/3494
- perf(rust): 基于共享的 bench.proto 数据重写 Rust benchmark,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3497
- feat(cpp): 为 c++ 增加 float16 支持,作者 @UninspiredCarrot,见 https://github.com/apache/fory/pull/3487
- feat(java): 增加 float 支持,作者 @mengnankkkk,见 https://github.com/apache/fory/pull/3254
- feat(java): 支持 java virtual threads,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3522
- perf(java): 优化 java 中线程安全 fory 的性能,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3529
- test(cpp): 为 ASAN 优化 float16 sign symmetry 测试,作者 @Geethapranay1,见 https://github.com/apache/fory/pull/3531
- feat(java): 增加专用 exception serializer,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3536
- refactor(java): 重构 fory java serialization API,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3537
- refactor(python): 重构 python serialization API,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3543
- feat(dart): 引入基于 id 的 enum serialization,作者 @yash-agarwa-l,见 https://github.com/apache/fory/pull/3482
- feat(javascript): 增加可配置的大小护栏,作者 @ayush00git,见 https://github.com/apache/fory/pull/3539
- feat(java): 通过在 Fory 实例间共享来降低 java serializer 内存占用,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3546
- refactor(javascript): 将 serialization 运行时状态移动到 contexts 中,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3549
- refactor(swift): 改进 swift API,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3554
- feat(xlang): 改进 xlang API 与 enum serialization,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3555
- feat(java): 从 fory java 中移除 guava 依赖,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3557
- refactor(dart): 全新的 dart 实现,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3551
- feat(compiler): 增加 JavaScript/TypeScript IDL 代码生成,作者 @miantalha45,见 https://github.com/apache/fory/pull/3394
- perf(javascript): 增加 javascript benchmark,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3562
- perf(dart): 使用直接分发代码生成为 struct 反序列化提速,作者 @yash-agarwa-l,见 https://github.com/apache/fory/pull/3563
- feat(dart): 增加 dart IDL 支持,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3571
- feat(python): 修复 python struct 跨语言引用跟踪错误,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3574
- feat: 让生成的 enum 在编码格式中使用 id,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3576
Bug 修复
- fix(java): 恢复 compact codec 定长优化,作者 @stevenschlansker,见 https://github.com/apache/fory/pull/3478
- fix(rust): 处理 fuzz 发现的边界场景引发的 panic,作者 @utafrali,见 https://github.com/apache/fory/pull/3481
- fix(rust): 为 std duration 增加错误处理逻辑,并支持 chrono duration,作者 @BaldDemian,见 https://github.com/apache/fory/pull/3490
- fix(compiler): 校验 rpc request/response 类型,作者 @retryoos,见 https://github.com/apache/fory/pull/3493
- fix(c++): 修复 UBSan 在 buffer.h 中检测到的未对齐地址访问错误,作者 @BaldDemian,见 https://github.com/apache/fory/pull/3479
- fix(java): 在首次使用时固定 codegen config hash,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3495
- fix(rust): 修复 cargo-fuzz 检测到的多个 panic,作者 @BaldDemian,见 https://github.com/apache/fory/pull/3483
- fix(java): 处理 private final map 的代码生成,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3504
- fix(compiler): 修复失效的 service 示例并补充回归覆盖,作者 @VikingDeng,见 https://github.com/apache/fory/pull/3505
- fix(rust): 深拷贝 TypeMeta,避免并发场景中的未定义行为,作者 @BaldDemian,见 https://github.com/apache/fory/pull/3511
- fix(compiler): 修复 compiler 测试失败问题,并增加 compiler CI,作者 @BaldDemian,见 https://github.com/apache/fory/pull/3516
- fix(compiler): 允许在 FDL RPC 签名中使用带限定名的嵌套类型,作者 @VikingDeng,见 https://github.com/apache/fory/pull/3518
- fix(java): 在复制时保留 ConcurrentSkipListSet comparator,作者 @mandrean,见 https://github.com/apache/fory/pull/3520
- test(compiler): 为 gRPC service 支持增加 IR 校验与代码生成测试,作者 @darius024,见 https://github.com/apache/fory/pull/3528
- fix(java): 修正 GraalVM 中依赖/嵌套 serializer 的解析,作者 @rakow,见 https://github.com/apache/fory/pull/3532
- fix(java): 修复 objectstream serializer 的异步 JIT 与 GraalVM 支持,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3534
- ci: 修复 C++ workflow 的 Bazel 缓存路径,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3535
- fix(python): 修复 visit_other 中错误的调用顺序,作者 @BaldDemian,见 https://github.com/apache/fory/pull/3542
- fix(js): 修正 float64 array 大小计算错误,作者 @ayush00git,见 https://github.com/apache/fory/pull/3541
- fix(java): 在构建期间配置 type checker,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3550
- fix(java): 为排序容器自动选择子 serializer,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3552
- fix(java): 支持在 java11+ 中跳过可选 SQL serializer,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3553
- fix(rust): 为嵌套类型统一应用 PascalCase 命名,作者 @utafrali,见 https://github.com/apache/fory/pull/3548
- fix(javascript): 修复不稳定的 javascript IDL 测试,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3565
- fix(swift): 修复 swift 生成代码的编译告警,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3566
- fix(java): 为此前遗漏的回归问题增加测试,作者 @PiotrDuz,见 https://github.com/apache/fory/pull/3573
其他改进
- chore(java): 更新 Spotless 和 Checkstyle,以支持使用 JDK25 构建,作者 @stevenschlansker,见 https://github.com/apache/fory/pull/3476
- chore(java): 清理 Javadoc 告警,并在引入新告警时让构建失败,作者 @stevenschlansker,见 https://github.com/apache/fory/pull/3477
- chore: 将版本号提升到 0.16.0,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3488
- docs: 在 readme 中增加 python benchmark 结果,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3496
- docs: 修复 benchmark 图表,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3498
- docs: 新增 fory code review skill,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3500
- chore: 调整 skills 软链接,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3501
- chore(cpp): 配置 CI,从 Markdown 中提取并执行 C++ 代码,作者 @Tyooughtul,见 https://github.com/apache/fory/pull/3381
- docs: 改进 Java generator 中的注释,作者 @codewithtarun2005,见 https://github.com/apache/fory/pull/3507
- docs: 重构 agents.md 以减少 token 使用,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3538
- docs: 增加 ai-review 策略,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3545
- chore: 在 /java/fory-test-core 中将 org.apache.logging.log4j:log4j-core 从 2.25.3 升级到 2.25.4,作者 @dependabot[bot],见 https://github.com/apache/fory/pull/3556
- chore(javascript): 将 ref tracking 重命名为 ref,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3559
- docs(dart): 增加 dart 文档,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3560
- docs(javascript): 增加 javascript 文档,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3561
- docs: 完善 dart 和 javascript 文档,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3567
- docs(dart): 更新 dart benchmark 文档,作者 @yash-agarwa-l,见 https://github.com/apache/fory/pull/3568
- docs: 更新 readme,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3575
新贡献者
- @utafrali 首次贡献见 https://github.com/apache/fory/pull/3481
- @BaldDemian 首次贡献见 https://github.com/apache/fory/pull/3490
- @retryoos 首次贡献见 https://github.com/apache/fory/pull/3493
- @Tyooughtul 首次贡献见 https://github.com/apache/fory/pull/3381
- @UninspiredCarrot 首次贡献见 https://github.com/apache/fory/pull/3487
- @VikingDeng 首次贡献见 https://github.com/apache/fory/pull/3505
- @codewithtarun2005 首次贡献见 https://github.com/apache/fory/pull/3507
- @darius024 首次贡献见 https://github.com/apache/fory/pull/3528
- @rakow 首次贡献见 https://github.com/apache/fory/pull/3532
- @PiotrDuz 首次贡献见 https://github.com/apache/fory/pull/3573
完整更新日志: https://github.com/apache/fory/compare/v0.16.0...v0.17.0
