Giter Site home page Giter Site logo

Comments (3)

dsyer avatar dsyer commented on September 27, 2024

Some more analysis breaks the 200ms down as follows (it includes transaction annotation processing as well):

50ms: pointcut processing for `@Cacheable`
50ms: pointcut processing for `@Transactional`
70ms: JCache (implementation from EhCache)
30ms: Spring Boot "overhead"

The pointcut processing could maybe be optimized away using an index of some sort - it is all about checking all the methods of all the beans for annotations, and 99% of the time there was no point even looking.

The cache initialization is native to JCache (or EhCache) but it can probably be deferred somehow, e.g. till the first time the cache is used.

The rest is mysterious. Best guess so far is that it is the sheer number of cache provider configurations that have to be processed (there are 10). There are some suspicious sources of possible slowness in there (like a linear search for a provider in a map), but none of them seem to account for the whole 30ms.

from spring-init.

dsyer avatar dsyer commented on September 27, 2024

A different experiment, slight more granular breakdown:

CacheBenchmarkIT.bench  annotation     empty  avgt   10  0.308 ± 0.009   s/op
CacheBenchmarkIT.bench  annotation    simple  avgt   10  0.386 ± 0.008   s/op
CacheBenchmarkIT.bench  annotation     cache  avgt   10  0.403 ± 0.010   s/op
CacheBenchmarkIT.bench  annotation    jcache  avgt   10  0.529 ± 0.043   s/op
CacheBenchmarkIT.bench  annotation    manual  avgt   10  0.368 ± 0.012   s/op

which translates to

60ms: pointcut processing = "manual" - "empty"
20ms: Spring Boot overhead - conditions, and import selection = "simple" - "manual"
10ms: beans added by Spring Framework to support JSR107 = "cache" - "simple"
120ms: JCache (actually EhCache) = "jcache" - "cache"

The "empty" sample has no caching. The "simple" sample is Spring Boot without JSR107 and manually selecting the cache type. The "cache" sample is the same, but with JSR107 on the classpath so Spring Framework adds some extra features. The "jcache" sample has EhCache as well and Spring Boot selects the cache provider.

There are no @Cacheable methods anywhere in the app (so all of the >200ms could be saved in principle).

from spring-init.

dsyer avatar dsyer commented on September 27, 2024

See https://jira.spring.io/browse/SPR-17646

from spring-init.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.