Skip to content

Reduce allocations from Redis operations #3207

Open
@theigl

Description

@theigl

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?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions