perf(StringRedisTemplate): avoid redundant logger creation in execute().#3173
perf(StringRedisTemplate): avoid redundant logger creation in execute().#3173huangcanda wants to merge 2 commits intospring-projects:3.5.xfrom
Conversation
Static logger eliminates expensive initialization per invocation. Signed-off-by: huangcanda <954060834@qq.com>
dcd43b7 to
41d4bda
Compare
|
Thanks for the heads up. There are a couple of other places in the codebase as well that would benefit from this kind of change. Would you like have a look and extend the PR to those, or should we take care of the rest. |
|
Sure, I’d be happy to extend the PR. However, since my initial change was based on a specific performance issue I encountered, I haven’t done a full review of the codebase. If you could point me to the places you think would benefit from similar optimizations, I’ll gladly take a look and update the PR accordingly. |
|
great - thank you! |
Signed-off-by: huangcanda <954060834@qq.com>
|
I've updated the PR based on your suggestions. Please review when convenient. Thanks! |
Problem Description
Each invocation of
StringRedisTemplate.execute()creates a newDefaultStringRedisConnectioninstance, resulting in repeated initialization of non-static logger instances. This causes redundantLogFactorylookups that consume an additional 10–15% CPU overhead.Solution
Modify the
private final Log loggerfield inDefaultStringRedisConnectiontoprivate static final Log logger.Impact
10–15% reduction in CPU overhead for all Redis client command executions.