wang-jiahua opened a new pull request, #10514: URL: https://github.com/apache/rocketmq/pull/10514
## Summary Four independent per-RPC micro-allocations eliminated in the remoting framework: ### 1. Guava Stopwatch → System.nanoTime() `RemotingCommand` used `Stopwatch.createStarted()` which allocates a new object per RPC. Replaced with `long processTimerNanos` + `processTimerElapsedMs()`. ### 2. Constructor cache `Class.getDeclaredConstructor()` copies the `Constructor` object on every call (~237 allocation events per 60s JFR). Added `ConcurrentHashMap<Class<?>, Constructor<?>> HEADER_CTOR_CACHE` with `computeIfAbsent` to pay the reflective lookup once per class. ### 3. Netty writability log downgrade `NettyRemotingServer.channelWritabilityChanged` logged at INFO/WARN on every writability change (~81,434 lines in 90s = ~900 lines/sec). Downgraded to DEBUG with `isDebugEnabled()` guard. ### 4. TopicQueueMappingContext.EMPTY singleton Non-static-topic messages (>99%) created empty `TopicQueueMappingContext` objects. Added `public static final EMPTY` singleton. ### Files Changed | File | Change | |---|---| | `remoting/.../protocol/RemotingCommand.java` | +56/-10: Stopwatch→nanoTime + Constructor cache + `newHeaderInstance()` + `setProcessTimerNanos()`/`processTimerElapsedMs()` | | `remoting/.../netty/NettyDecoder.java` | +2/-3: `Stopwatch` → `System.nanoTime()` + `setProcessTimerNanos()` | | `remoting/.../netty/NettyRemotingServer.java` | +8/-4: `channelWritabilityChanged` INFO/WARN → DEBUG with `isDebugEnabled()` guard | | `remoting/.../protocol/statictopic/TopicQueueMappingContext.java` | +2: `EMPTY` static singleton | -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
