Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lazy cache provider initialization [SPR-17646] #22175

Open
spring-projects-issues opened this issue Jan 8, 2019 · 3 comments
Open

Lazy cache provider initialization [SPR-17646] #22175

spring-projects-issues opened this issue Jan 8, 2019 · 3 comments

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues spring-projects-issues commented Jan 8, 2019

Dave Syer opened SPR-17646 and commented

Several opportunities:

  • Pointcut processing is expensive, and involves reflecting on all methods of all beans. Clearly this doesn't scale well and could be indexed away. Could also be used with @Transactional (and @Secured etc.).
  • The cache provider (e.g. EhCache) has expensive internal initialization. This could perhaps be deferred until the cache is actually used.
  • Some other stuff in Spring Boot might help (condition evaluation and import selection)

Some analysis and benchmarks here: spring-projects-experimental/spring-init#5


Affects: 5.1.3

Reference URL: spring-projects-experimental/spring-init#5

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Jan 9, 2019

Stéphane Nicoll commented

The cache provider (e.g. EhCache) has expensive internal initialization. This could perhaps be deferred until the cache is actually used.

Just a note that several things may go wrong (configuration file not found, configuration invalid, network topology that has to be validated on startup) so whatever we do here should be opt-in. It would be nice though if we wouldn't have to do that for every single component that we optimize this way

@snicoll
Copy link
Member

@snicoll snicoll commented Feb 1, 2019

Some additional data point here https://github.com/scratches/spring-cache-bench

@jhoeller
Copy link
Contributor

@jhoeller jhoeller commented Mar 12, 2019

For a start, #22420 covers the pointcut processing part: We are not traversing classes now if they are known to not declare the desired annotation type. This is implemented for our async, caching, and transaction annotations, ignoring java* classes by default but also participating in the single unified hook (AnnotationUtils.isCandidateClass) which we have for our upcoming indexer integration.

@jhoeller jhoeller changed the title Optimizations for @Cacheable methods [SPR-17646] Lazy cache provider initialization [SPR-17646] Mar 12, 2019
@jhoeller jhoeller modified the milestones: 5.2 M1, 5.2 M2 Mar 12, 2019
@jhoeller jhoeller removed their assignment Mar 27, 2019
@jhoeller jhoeller modified the milestones: 5.2 M2, 5.x Backlog Mar 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants