Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

perf(StringRedisTemplate): avoid redundant logger creation in execute(). #3173

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
huangcanda wants to merge 2 commits into spring-projects:3.5.x
base: 3.5.x
Choose a base branch
Loading
from huangcanda:fix/string-redis-template-connection-perf

Conversation

Copy link

@huangcanda huangcanda commented Jun 22, 2025

Problem Description

Each invocation of StringRedisTemplate.execute() creates a new DefaultStringRedisConnection instance, resulting in repeated initialization of non-static logger instances. This causes redundant LogFactory lookups that ​consume an additional 10–15% CPU overhead.

Solution

Modify the private final Log logger field in DefaultStringRedisConnection to private static final Log logger.

Impact

10–15% reduction in CPU overhead for all Redis client command executions.

Static logger eliminates expensive initialization per invocation.
Signed-off-by: huangcanda <954060834@qq.com>
@huangcanda huangcanda force-pushed the fix/string-redis-template-connection-perf branch from dcd43b7 to 41d4bda Compare June 22, 2025 07:37
@mp911de mp911de added type: task A general task and removed status: waiting-for-triage An issue we've not yet triaged labels Jun 23, 2025
Copy link
Member

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.

@christophstrobl christophstrobl added the status: waiting-for-feedback We need additional information before we can continue label Jul 10, 2025
Copy link
Author

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.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Jul 15, 2025
Copy link
Member

great - thank you!
I think we should also change the following: DefaultStreamReceiver, JedisClusterConnection, JedisConnection, JedisConnectionFactory, LettuceClusterConnection, LettuceConnection, LettuceConnectionFactory, RedisAccessor, RedisKeyValueAdapter, RedisMessageListenerContainer, MessageListenerAdapter

@christophstrobl christophstrobl removed the status: feedback-provided Feedback has been provided label Jul 25, 2025
Signed-off-by: huangcanda <954060834@qq.com>
Copy link
Author

I've updated the PR based on your suggestions. Please review when convenient. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers
No reviews
Labels
type: task A general task
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /