Skip to content
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

Reduce allocations from Redis operations #3207

Open
theigl opened this issue Sep 19, 2024 · 0 comments
Open

Reduce allocations from Redis operations #3207

theigl opened this issue Sep 19, 2024 · 0 comments
Labels
status: waiting-for-triage An issue we've not yet triaged type: enhancement A general enhancement

Comments

@theigl
Copy link
Contributor

theigl commented Sep 19, 2024

RedisIndexedSessionRepository and RedisSessionExpirationPolicy create a lot of single-use proxies by relying on BoundHashOperations.

For instance in this case:

private void saveDelta() {
if (this.delta.isEmpty()) {
return;
}
String sessionId = getId();
getSessionBoundHashOperations(sessionId).putAll(this.delta);

private BoundHashOperations<String, String, Object> getSessionBoundHashOperations(String sessionId) {
String key = getSessionKey(sessionId);
return this.sessionRedisOperations.boundHashOps(key);

This showed up in our production profiler because of hundreds of MB allocated in java.lang.reflect.Method:

image

If I understand the code correctly, this is done purely for convenience and could simply be replaced by the following code:

String key = getSessionKey(sessionId);
sessionRedisOperations.opsForHash().putAll(key, this.delta);

Or am I overlooking something?

@theigl theigl added status: waiting-for-triage An issue we've not yet triaged type: enhancement A general enhancement labels Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-triage An issue we've not yet triaged type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

1 participant