-
Notifications
You must be signed in to change notification settings - Fork 7
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
#203: Expand caching + general improvements #204
Merged
marcus-talbot42
merged 11 commits into
master
from
improvement/203-Expand-caching-to-include-other-expensive-unchanging-operations
Apr 11, 2024
Merged
#203: Expand caching + general improvements #204
marcus-talbot42
merged 11 commits into
master
from
improvement/203-Expand-caching-to-include-other-expensive-unchanging-operations
Apr 11, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Contributor
marcus-talbot42
commented
Apr 11, 2024
- Added CanonicalClassNameStore, saving the canonical names of classes, in order to prevent repeated reflective access.
- Added caching for the selection of valid BeanConverters.
- Replaced most usages of TreeMap with some form of HashMap, in order to improve performance.
In order to lower the impact of reflective access, we add the CanonicalClassNameStore, saving the canonical name of classes. - Created CanonicalClassNameStore - Updated direct calls to CanonicalClassName#determineCanonicalClassName calls to the CanonicalClassNameStore#getOrComputeClassName.
As some BeanConverters should only be added within the relevant scope, it turned out to be impossible to create a global store. Rather than that, we create an instance of the BeanConverterStore only in the CoreConfiguration, and in the first layer OverrideConfiguration. As the OverrideConfigurations are stripped from the CoreConfiguration after a successful mapping, this should guarantee that any cache built up within OverrideConfigurations is not propagated to the cache within the CoreConfiguration, while allowing the CoreConfiguration to form its own cache. - Updated BeanConverterStore, to make it publicly instantiable. - Updated CoreConfiguration and OverrideConfiguration, to include the BeanConverterStore. - Updated AbstractMapStrategy, to use the BeanConverterStore whenever possible.
As BeanMapper largely doesn't use TreeMaps anymore, for performance reasons, tests needed to be updated to reflect the unordered nature of Maps in BeanMapper.
Updated BeanMatchStore, to use faster collections, and remove the need for (relatively) expensive calls to get the names of classes, by simply passing the classes themselves. Since classes have an excellent hashCode-implementation, using classes as the key for the data store, in combination with the relatively fast HashMap, makes more sense than using the TreeMap.
Replaced the use of a TreeMap, with the use of a ConcurrentHashMap, for slightly better performance.
Removed OverrideField, in preparation for the next release.
As using a TreeMap for incomparable elements causes problems, the MapCollectionHandler now creates a HashMap by default.
Through analysis of what can actually change in the OverrideConfiguration, it now uses direct references to the collection in the parent when the collection cannot be edited in the OverrideConfiguration.
Changed the call to the BeanMapperTraceLogger, to no longer evaluate the String before it is logged.
- Updated CoreConfiguration to be able to get a BeanConverter from it.
sptdevos
reviewed
Apr 11, 2024
beanConverterMap.forEach((key, value) -> this.beanConverterMap.put(key, new HashMap<>(value))); | ||
} | ||
|
||
public BeanConverter get(Class<?> source, Class<?> target) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is wel beter als de get
en de add
synchronized zijn.
- Made #get and #add synchronized.
sptdevos
approved these changes
Apr 11, 2024
marcus-talbot42
deleted the
improvement/203-Expand-caching-to-include-other-expensive-unchanging-operations
branch
April 11, 2024 08:39
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.