跳到主要内容

Fory v0.15.0 Released

· 阅读需 14 分钟
Shawn Yang

The Apache Fory team is pleased to announce the 0.15.0 release. This is a major release that includes 144 PR from 17 distinct contributors. See the Install Page to learn how to get the libraries for your platform.

Highlights

Go Serialization: First Release

Apache Fory 0.15.0 is the first release with official Go serialization support. The Go implementation delivers high-performance serialization with cross-language compatibility and production-focused configuration options.

Key capabilities:

  • Cross-language mode with Java, Python, cpp, Rust, and JavaScript (fory.WithXlang(true))
  • Reflection-based serialization by default, plus optional experimental AOT code generation for hot paths
  • Reference tracking for shared/circular object graphs (fory.WithTrackRef(true) + fory:"ref" tags)
  • Compatible mode for schema evolution (fory.WithCompatible(true)) supporting add/remove/reorder field changes
  • Thread-safe wrapper (github.com/apache/fory/go/fory/threadsafe) for concurrent workloads

Quick Start

package main

import (
"github.com/apache/fory/go/fory"
)

type User struct {
ID int64
Name string
}

func main() {
f := fory.New(
fory.WithXlang(true),
fory.WithCompatible(true),
)
_ = f.RegisterStruct(User{}, 1)

data, _ := f.Serialize(&User{ID: 1, Name: "Alice"})
var out User
_ = f.Deserialize(data, &out)
}

Go Benchmarks

Below are timing results (ns/op; lower is better) comparing Fory with Protobuf and Msgpack across representative data structures.

Data TypeOperationForyProtobufMsgpack
StructSerialize66.097.8184.9
StructDeserialize82.790.9309.6
StructlistSerialize632.81783.03340.0
StructlistDeserialize906.41891.05709.0
SampleSerialize137.3367.31492.0
SampleDeserialize263.6422.22661.0
SamplelistSerialize1962.07087.026169.0
SamplelistDeserialize4234.09321.053615.0
MediacontentSerialize268.8471.1773.7
MediacontentDeserialize426.9553.11432.0
MediacontentlistSerialize3736.09107.013911.0
MediacontentlistDeserialize7247.011435.027975.0

Serialized data sizes (bytes):

Data TypeForyProtobufMsgpack
Struct586157
Sample446375524
MediaContent342301400
StructList56012601146
SampleList7600756010486
MediaContentList577660808006

Note: Results depend on hardware and implementation versions. See the Go benchmark docs for details: https://fory.apache.org/docs/benchmarks/go/

Fory Schema IDL and Compiler: First Release

Apache Fory 0.15.0 also introduces the first release of the Fory schema IDL and compiler toolchain. You can define schemas once and generate native types and registration code across languages.

Key capabilities:

  • Schema-first development with enum, message, and union
  • Fory-native field semantics: optional (nullability), ref (shared/circular references), list, and map
  • Multi-language code generation for Java, Python, Go, Rust, and cpp
  • Protobuf (.proto) and FlatBuffers (.fbs) frontend support, translated into Fory IR/codegen
  • Idiomatic generated APIs with to/from bytes helpers

Quick Start

pip install fory-compiler
foryc example.fdl --lang java,python,go,rust,cpp --output ./generated
package example;

message Person [id=101] {
string name = 1;
optional string email = 2;
}

Generated Code Example

foryc generates idiomatic native types plus registration/byte helpers. For the schema above, generated code looks like:

// Go (excerpt)
type Person struct {
Name string `fory:"id=1"`
Email optional.Optional[string] `fory:"id=2"`
}

func (m *Person) ToBytes() ([]byte, error) { ... }
func (m *Person) FromBytes(data []byte) error { ... }
func RegisterTypes(f *fory.Fory) error {
return f.RegisterStruct(Person{}, 101)
}
// Java (excerpt)
public class Person {
@ForyField(id = 1)
private String name;

@ForyField(id = 2, nullable = true)
private String email;

public byte[] toBytes() { ... }
public static Person fromBytes(byte[] bytes) { ... }
}
# Python (excerpt)
@pyfory.dataclass
class Person:
name: str = pyfory.field(id=1, default="")
email: Optional[str] = pyfory.field(id=2, default=None)

def to_bytes(self) -> bytes: ...
@classmethod
def from_bytes(cls, data: bytes) -> "Person": ...

Features

Bug Fix

Other Improvements

New Contributors

Full Changelog: https://github.com/apache/fory/compare/v0.14.1...v0.15.0