netty 按需声明,并记录 jar 运行期的低内存调优

netty-all 是聚合 pom,会拖进 5 个平台的 native-quic、各架构的 epoll/kqueue/
io_uring 传输以及 htt3/mqtt/redis 等一堆用不到的 codec。主站实际只用
Bootstrap/NioEventLoopGroup/NioSocketChannel/ByteBuf/ByteToMessageCodec/
LengthFieldBasedFrameDecoder/LoggingHandler/Promise,因此收敛为
transport + codec-base + handler(含 buffer/common/resolver 传递依赖)。

效果:jar 68.1MB -> 52.2MB,netty 模块 50 -> 7,进程 RSS 291MB -> 约 227MB。
433 个测试全绿。hutool 未动。

同时把 jar 运行期的 systemd JVM 参数与前后实测数据记入
docs/MEMORY_TUNING_2026-09-21.md,避免这些只存在于服务器 drop-in 的参数
在下次重新部署时丢失。
This commit is contained in:
root
2026-09-21 17:27:17 +08:00
parent 5f1066cdab
commit e03a2e007b
2 changed files with 100 additions and 1 deletions
+22 -1
View File
@@ -86,7 +86,28 @@
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<!--
只保留实际用到的模块。原先的 netty-all 是聚合 pom,会拖进 50 个模块
(含 5 个平台的 native-quic、aarch64/riscv64/osx 的 epoll/kqueue/io_uring、
codec-http3/mqtt/redis/smtp/stomp/xml/protobuf 等),
而本项目只用 Bootstrap/NioEventLoopGroup/NioSocketChannel/ByteBuf/
ByteToMessageCodec/LengthFieldBasedFrameDecoder/LoggingHandler/Promise。
transport 提供 Bootstrap/EventLoop/Channel,codec-base 提供
ByteToMessageCodec 与 LengthFieldBasedFrameDecoder,handler 提供
LoggingHandler(RemoteService 的协议调试日志用)。
buffer/common/resolver 由它们传递引入。
-->
<artifactId>netty-transport</artifactId>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-codec-base</artifactId>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-handler</artifactId>
</dependency>
<dependency>