doc[protocol]: update document

This commit is contained in:
godotg committed 2023-10-28 09:15:48 +08:00
1 parent 1ec936b6c0
commit 6d0dc5168f
6 files changed
+97 -12

No files matched your search

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 64 KiB

+50 -6
View File
@@ -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
```
+45 -4
View File
@@ -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文件
```
<protocols>
@@ -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
```
支持集合嵌套语法
```
@@ -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();