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

Performance issue on ResolvableType cache [SPR-12122] #16738

Closed
spring-projects-issues opened this issue Aug 26, 2014 · 1 comment
Closed

Performance issue on ResolvableType cache [SPR-12122] #16738

spring-projects-issues opened this issue Aug 26, 2014 · 1 comment
Assignees
Labels
status: backported type: enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues spring-projects-issues commented Aug 26, 2014

Sébastien Deleuze opened SPR-12122 and commented

While working on Spring Flex issue FLEX-234, I have found that the ResolvableType cache can be really slow.

When there is a lot of entries in this HashMap, getting a simple value could take a lot of time, and the bottleneck seems to come from a lot of calls to ResolvableType.equals().

ResolvableType.equals() uses this.type, getSource(), this.variableResolver.getSource() and this.componentType but ResolvableType.hashCode() uses only this.type. This seems to be the root cause of these huge amount of slow equals() calls when ResolvableType.forType() try to get a value from the HashMap.

By using the same fields in ResolvableType.hashCode() than in ResolvableType.equals(), we should be able to improve performances.

I have created a benchmark project that reproduce this issue.


Affects: 4.0.6, 4.1 RC2

Reference URL: https://github.com/sdeleuze/spring-resolvabletype-benchmark

Issue Links:

  • FLEX-234 Poor performance stemming from ObjectUtils.nullSafeEquals() calls ("is depended on by")
  • #16021 memory leak in class org.springframework.core.ResolvableType

Backported to: 4.0.7

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Aug 26, 2014

Sébastien Deleuze commented

Pull request #635 submitted.

With real applications, where ResolvableCache contains thousands of entries, this improvement could allow great performances improvements. For example on the spring-resolvabletype-benchmark project:

  • 8000 us before this commit
  • 120 us with this commit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: backported type: enhancement
Projects
None yet
Development

No branches or pull requests

2 participants