'Why are the objcet converters provided by spring-data-redis to slow?

I would like to know why the classes that are in charge of converting an object to a redis hash are so slow. In particular I have tried to use these 2 classes with StringRedisTemplate:

private final HashMapper<YardStack, String, String> hashMapper = new DecoratingStringHashMapper(new Jackson2HashMapper(true));
private final HashMapper<Object, byte[], byte[]> mapper = new ObjectHashMapper();

To save 27000 records it takes 24 seconds for the first converter and 2 seconds for the second (it is less but still a lot).

Finally I have tested the conversion with the following class:

private final ObjectMapper objectMapper = new ObjectMapper();

and takes 200 milliseconds, but this method is not the one offered by spring-data-redis.

It should be noted that the benchmark has been performed by iterating over the elements and performing only the conversion, without saving anything in redis.

I do not understand how it is possible that the conversion from an object to a map is so slow, and even less using the classes offered by spring. Maybe I have left some important configuration parameter, I don't know, please help.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source