micronaut-projects / micronaut-projects/micronaut-cache

Allow disabling of conversion of cache data

Open
#122 11 comments 0 reactions 1 assignee View on GitHub

@jameskleeh is already working on this.

Since Feb 18, 2020.

type: enhancement
Dominant language
PLSQL
Stars
32
Forks
36
Avg merge
2h 2m
Merged PRs (30d)
5

Description

### Task List

- [x] Steps to reproduce provided

### Steps to Reproduce

1. Write a method which returns a huge map and annotate it with `@Cacheable`
1. Call that method
1. Call it again

### Expected Behaviour

2nd method call is at least as fast as 1st.

### Actual Behaviour

2nd method call is a lot slower.

### Environment Information

- **Operating System**: Fedora 31
- **Micronaut Version:** 1.3.0
- **JDK Version:** AdoptJDK 11.0.6

Hi,

the DefaultSyncCache uses [the conversion service](https://github.com/micronaut-projects/micronaut-core/blob/1.3.x/runtime/src/main/java/io/micronaut/cache/DefaultSyncCache.java#L56) to [convert the stuff](https://github.com/micronaut-projects/micronaut-core/blob/1.3.x/runtime/src/main/java/io/micronaut/cache/DefaultSyncCache.java#L124) coming from the actual cache implementation. The `DefaultConversionService` contains some code which iterates over all the keys from map (because it implements Iterable) and tries to convert them. I'm not sure why it's doing this, but this caused a huge performance hit in our application. We're using the default in-memory caffeine cache.

We worked around by wrapping the huge map in an object which doesn't implement Iterable and now it's fast again.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.