diff --git a/doc/image/protocol/complex_object.png b/doc/image/protocol/complex_object.png index 68ce0f7d..e0f2fe2f 100644 Binary files a/doc/image/protocol/complex_object.png and b/doc/image/protocol/complex_object.png differ diff --git a/doc/image/protocol/normal_object.png b/doc/image/protocol/normal_object.png index 1a21b162..745db80a 100644 Binary files a/doc/image/protocol/normal_object.png and b/doc/image/protocol/normal_object.png differ diff --git a/doc/image/protocol/simple_object.png b/doc/image/protocol/simple_object.png index be652c17..7c28febf 100644 Binary files a/doc/image/protocol/simple_object.png and b/doc/image/protocol/simple_object.png differ diff --git a/protocol/README.md b/protocol/README.md index bd0c66dc..7af5708a 100644 --- a/protocol/README.md +++ b/protocol/README.md @@ -33,18 +33,14 @@ var packet = ProtocolManager.read(buffer); ### Ⅲ. Performance testing -- Single-threaded environment, 50% faster than Protobuf and 100% faster than Kryo without any JVM parameter - tuning,[参见性能测试](src/test/java/com/zfoo/protocol/BenchmarkTesting.java) -- Thread safety, the performance of zfoo and Protobuf is not affected in any way, kryo will lose some performance - because of thread insecurity,[参见性能测试](src/test/java/com/zfoo/protocol/BenchmarkTesting.java) - +- [Benchmark Test](src/test/java/com/zfoo/protocol/BenchmarkTesting.java) - Test the environment ``` system:win10 cpu: i9900k -内存:64g +memory:64g ``` - Single-threaded test with abscissa as the number of objects serialized and deserialized and time spent in milliseconds @@ -197,4 +193,52 @@ your protocol number a little more compactly, so that your protocol number will [Use code custom generation to proto](https://github.com/zfoo-project/tank-game-server/tree/main/common/src/main/java/com/zfoo/tank/common/generate) +### Ⅸ. The difference between zfoo and Protobuf + +- Abandoning the deletion field of protobuf can also be compatible with the protocol, improving the performance by 1 times and reducing the cost by 1 times. + +- zfoo takes the intersection of type declarations in all languages, instead of protobuf taking the union, simplifying the type implementation of protobuf + - protobuf + ``` + double + float + int32 + int64 + uint32 + uint64 + sint32 + sint64 + fixed32 + fixed64 + sfixed32 + sfixed64 + bool + string + bytes + bytes + ``` + - zfoo + ``` + float + double + byte + int16 + int32 + int64 + bool + string + ``` + +- zfoo takes the intersection of the grammars of all languages, instead of the intersection of protobuf, and adds the grammar implementation of protobuf + - protobuf + ``` + Collection nesting syntax is not supported + ``` + - zfoo + ``` + Supports nested collection syntax + ``` + + + diff --git a/protocol/README_CN.md b/protocol/README_CN.md index 1b559c5b..aef8fbcd 100644 --- a/protocol/README_CN.md +++ b/protocol/README_CN.md @@ -26,9 +26,7 @@ var packet = ProtocolManager.read(buffer); ### Ⅲ. 性能测试 -- 单线程环境,在没有任何JVM参数调优的情况下速度比Protobuf快50%,比Kryo快100%,[参见性能测试](src/test/java/com/zfoo/protocol/BenchmarkTesting.java) - -- 线程安全,zfoo和Protobuf的性能不受任何影响,kryo因为线程不安全性能会有所损失,[参见性能测试](src/test/java/com/zfoo/protocol/BenchmarkTesting.java) +- [性能测试](src/test/java/com/zfoo/protocol/BenchmarkTesting.java) - 测试环境 @@ -128,7 +126,7 @@ cpu: i9900k } ``` - + - 第三种使用:通过ProtocolManagerinitProtocol(xmlProtocols)去注册协议,把协议号写在protocol.xml文件 ``` @@ -160,5 +158,48 @@ cpu: i9900k - 也可以自定义自己的生成方式, [使用代码自定义生成proto](https://github.com/zfoo-project/tank-game-server/tree/main/common/src/main/java/com/zfoo/tank/common/generate) +### Ⅸ. zfoo和Protobuf的区别 +- 舍弃protobuf的删除字段也可以兼容协议的方式,提升1倍的性能,减小1倍的 +- zfoo取所有语言的类型声明的交集,而不是protobuf取并集,简化protobuf的类型实现 + - protobuf + ``` + double + float + int32 + int64 + uint32 + uint64 + sint32 + sint64 + fixed32 + fixed64 + sfixed32 + sfixed64 + bool + string + bytes + bytes + ``` + - zfoo + ``` + float + double + byte + int16 + int32 + int64 + bool + string + ``` + +- zfoo取所有语言的语法的交集,而不是protobuf的交集,增加protobuf的语法实现 + - protobuf + ``` + 不支持集合嵌套语法 + ``` + - zfoo + ``` + 支持集合嵌套语法 + ``` diff --git a/protocol/src/test/java/com/zfoo/protocol/BenchmarkTesting.java b/protocol/src/test/java/com/zfoo/protocol/BenchmarkTesting.java index cf56c981..b8ef2b66 100644 --- a/protocol/src/test/java/com/zfoo/protocol/BenchmarkTesting.java +++ b/protocol/src/test/java/com/zfoo/protocol/BenchmarkTesting.java @@ -69,8 +69,8 @@ public class BenchmarkTesting { zfooTest(); furyTest(); - protobufTest(); kryoTest(); + protobufTest(); // 递归执行,多跑几遍 benchmark = benchmark * 2; @@ -91,8 +91,8 @@ public class BenchmarkTesting { zfooMultipleThreadTest(); furyMultipleThreadTest(); - protobufMultipleThreadTest(); kryoMultipleThreadTest(); + protobufMultipleThreadTest(); benchmark = benchmark * 2; multipleThreadBenchmarks();