Kitex Release v0.10.0
项目:
重要变更介绍
性能优化
新版本探索了更多性能优化的方向和非常规的一些优化手段。
- 长连接池: 100 并发 qps 提升 4%, p99 降低 18%
- 多路复用: 100 并发 qps 提升 7%, p99 降低 24%
- gRPC: 100 并发 qps优化 8%,p99优化 10%
代码产物精简优化
- 移除非序列化代码(默认):原 kitex_gen Thrift 产物代码为保持与 Apache 的一致性,会生成 Processor 代码,但 Kitex 并不需要这些代码。为解决大家的产物痛点问题,此版本默认去除这部分代码,生成速度提升约10%。
- 移除 Apache Codec 代码(配置移除):Kitex 有自定义的 FastCodec 代码,旧版本仅在 Buffered 包需要使用 Apache Codec。Kitex 新版本实现 SkipDecoder,在开启后就可以完全不依赖 Apache Codec,进而移除代码,产物体积可减少约50%。使用方式见 SkipDecoder
新特性
- Thrift 按需序列化:支持定义 FieldMask 实现数据按需序列化(字段裁剪、合并,RPC性能优化等),详见 Thrift FieldMask RFC
功能优化
- 熔断:支持自定义熔断的错误类型
- 异常重试:代码配置的自定义结果重试增加 ctx 参数,方便用户结合 ctx 信息判断是否重试
- 移除一致性哈希中的缓存:解决hash key分散导致的延迟变高、内存上涨的问题。移除缓存后,面对 Key 特别分散甚至接近随机分布的场景,可以有效降低内存占用与管理缓存的消耗。
用户体验优化
- Kitex 工具兼容性检测:优化过去产物引入新定义导致的 undefined 编译问题。Kitex 工具在生成代码前会检查 go.mod 中使用的 Kitex 版本。若 Kitex 工具和 Kitex 版本不兼容,则不会生成代码并给出相应的升降级提示。
详细变更
Feature:
- [#1370] feat(loadbalance): do not cache all the keys for Consistent Hash
- [#1359] feat:(generic) jsonpb using dynamicgo support parse IDL from memory
- [#1353] feat(retry): add ctx param for customized result retry funcs
- [#1352] feat: add option to specify ip version for default HTTPResolver
- [#1316] feat(kitex tool): support dependencies compatibility checking
- [#1346] feat(generic): set dynamicgo parse mode
- [#1336] feat(tool): fast-codec supports Thrift Fieldmask
- [#1313, #1378] feat(thrift codec): implement skipDecoder to enable Frugal and FastCodec for standard Thrift Buffer Protocol
- [#1257] feat: CBSuite custom GetErrorType func
Optimize:
- [#1349] optimize(gRPC): gRPC onError uses CtxErrorf to print log with information in ctx
- [#1326] optimize(tool): remove thrift processor for less codegen
Perf:
- [#1369] perf(thrift): optimized skip decoder
- [#1314] perf: use dirtmake to reduce memclr cost
- [#1322] perf(codec): support fast write nocopy when using netpoll link buffer
- [#1276] perf: linear allocator for fast codec ReadString/ReadBinary
- [#1320] perf(codec): fast codec use batch alloc
Fix:
- [#1379] fix: fix a bug “unknown service xxx” when using generic client by not writing IDLServiceName when it’s generic service
- [#1368] fix(remote): modify the error message thrown when no target service is found
- [#1374] fix: init default values when using liner allocator
- [#1361] fix: span cache re-cap bytes when using Make
- [#1362] fix(payloadCodec): replace the registered PayloadCodec if the type is same when using WithPayloadCodec for server-side
- [#1364] fix: fix grpc compressor mcache free panic when data is empty
- [#1328] fix(gRPC): release connection in DoFinish for grpc streaming to close the short connection
- [#1307] fix(connpool): kitex long pool reset idleList element to nil to prevent conn leak
- [#1294] fix(netpollmux): fix a bug that disables multi-service by assigning the first svcInfo to targetSvcInfo
- [#1308] fix(generic): not write generic method name for binary generic exception to align with method names of services not using binary generic
Refactor:
- [#1344] refactor(tool): export thriftgo template definition in kitextool
Chore:
- [#1385] chore: update dynamicgo to v0.2.8
- [#1383] chore: upgrade netpoll to v0.6.1
- [#1376] chore: integration test use go 1.20 to solve the compatibility issue of official gRPC in kitex-tests repo
- [#1355] chore: upgrade netpoll to v0.6.1 pre-release version
- [#1338] chore: correct the comment of FreezeRPCInfo
- [#1347] chore: use runtimex to replace choleraehyq/pid
- [#1342] chore: update sonic/loader to v0.1.1
- [#1334] chore: update dynamicgo to v0.2.3
- [#1324] chore: update dynamicgo and sonic version
- [#1317] chore: frugal v0.1.15 (with migrated iasm)
Thanks a lot to those community contributors who submit some pull requests or share your ideas for this version: @XiaoYi-byte