Skip to content

Commit

Permalink
doc[protocol]: update document
Browse files Browse the repository at this point in the history
  • Loading branch information
jaysunxiao committed Oct 28, 2023
1 parent 1ec936b commit 6d0dc51
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 12 deletions.
Binary file modified doc/image/protocol/complex_object.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/image/protocol/normal_object.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/image/protocol/simple_object.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
56 changes: 50 additions & 6 deletions protocol/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
```
49 changes: 45 additions & 4 deletions protocol/README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)


- 测试环境
Expand Down Expand Up @@ -128,7 +126,7 @@ cpu: i9900k
}
```
- 第三种使用:通过ProtocolManagerinitProtocol(xmlProtocols)去注册协议,把协议号写在protocol.xml文件
```
<protocols>
Expand Down Expand Up @@ -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
```
支持集合嵌套语法
```
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ public void singleThreadBenchmarks() {

zfooTest();
furyTest();
protobufTest();
kryoTest();
protobufTest();

// 递归执行,多跑几遍
benchmark = benchmark * 2;
Expand All @@ -91,8 +91,8 @@ public void multipleThreadBenchmarks() throws InterruptedException {

zfooMultipleThreadTest();
furyMultipleThreadTest();
protobufMultipleThreadTest();
kryoMultipleThreadTest();
protobufMultipleThreadTest();

benchmark = benchmark * 2;
multipleThreadBenchmarks();
Expand Down

0 comments on commit 6d0dc51

Please sign in to comment.