micronaut-projects / micronaut-projects/micronaut-cache
Allow disabling of conversion of cache data
@jameskleeh is already working on this.
Since Feb 18, 2020.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.