From 8ecc82da7559a89a895c06af36eb16691522daa8 Mon Sep 17 00:00:00 2001 From: sun Date: Fri, 20 Oct 2023 17:58:40 +0800 Subject: [PATCH] doc[protocol]: update doc --- protocol/README.md | 41 +++++++++++++++++++++++------------------ protocol/README_CN.md | 1 + 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/protocol/README.md b/protocol/README.md index e6908a1f..bd0c66dc 100644 --- a/protocol/README.md +++ b/protocol/README.md @@ -2,8 +2,10 @@ English | [简体中文](./README_CN.md) ### Ⅰ. Introduction -- A decentralized serialization library, secure, private, reliable, and compatible, allowing everyone to have a unique set of protocols -- The protocol is currently natively supported **C++ Java Javascript TypeScript C# Go Lua GDScript Python**,It's easy to do cross-platform +- A decentralized serialization library, secure, private, reliable, and compatible, allowing everyone to have a unique + set of protocols +- The protocol is currently natively supported **C++ Java Javascript TypeScript C# Go Lua GDScript Python**,It's easy to + do cross-platform - The protocol can customize the private protocol format to make your protocol more secure, and supports adding fields and being compatible with previous and subsequent protocols - Compatible with Protobuf, it supports the generation of Protobuf protocol files, and provides a generation method from @@ -66,6 +68,8 @@ cpu: i9900k as List>>; Comparing kryo and protobuf data structure nesting results in a performance penalty - There is no risk of vulnerability injection, only bytecode enhancement will be performed during initialization, and no bytecode operations will be performed in the later stage +- Taking advantage of the principle of program locality, the serializer is placed in the short[] array, and the object + serialization and deserialization will only look for the serializer once ``` The data compression volume is small, and the compression volume is smaller than that of Kryo and Protobuf; Smaller than kryo because kryo needs to write the registration number of each object @@ -95,7 +99,8 @@ For complex objects, ZFOO package size 2216, KRYO package size 2528, and Protobu - Default data format support eliminates the need for users to register manually.[参考类定义](src/test/java/com/zfoo/protocol/packet/ComplexObject.java) - boolean,byte,short,int,long,float,double,String - - Boolean,Byte,Short,Integer,Long,Float,Double,String,If it is null during serialization, a default value will be given + - Boolean,Byte,Short,Integer,Long,Float,Double,String,If it is null during serialization, a default value will be + given - int[],Integer[],If it is null, it is parsed as an array of length 0 - Native generic List, Set, Map, deserialization return type Hash Set, Array List, Hash Map, and null pointer safe (returns a collection of size 0) @@ -151,21 +156,21 @@ your protocol number a little more compactly, so that your protocol number will } ``` - - - The third use: Register the protocol through ProtocolManager.initProtocol(xmlProtocols) in the protocol.xml file - ``` - - - - - - - - - - - - ``` + + - The third use: Register the protocol through ProtocolManager.initProtocol(xmlProtocols) in the protocol.xml file + ``` + + + + + + + + + + + + ``` - If you add a field for version compatibility, you need to add a Compatible annotation, and the order needs to be naturally increased, so as to ensure that the old and new protocols can be compatible with each other diff --git a/protocol/README_CN.md b/protocol/README_CN.md index b0bbf484..1b559c5b 100644 --- a/protocol/README_CN.md +++ b/protocol/README_CN.md @@ -53,6 +53,7 @@ cpu: i9900k - 没有反射,没有unsafe操作;对比kryo中使用objenesis导致大量unsafe,而且在Java11中运行会出现警告 - 扁平化了方法栈的调用深度,数据结构嵌套没有任何性能损失,如List>>;对比kryo和protobuf数据结构嵌套会出现性能损失 - 无漏洞注入风险,只有初始化时会进行字节码增强,后期不会再进行任何字节码的操作 +- 充分利用程序局部性原理,序列化器放在short[]数组中,对象序列化和反序列化只会查找一次序列化器 ``` 数据压缩体积小,压缩体积比kryo和protobuf都要小;比kryo小是因为kryo需要写入每个对象的注册号