Cache ObjectMappers to prevent continual recursion during dynamic mapper building#103858
Closed
benwtrent wants to merge 3 commits intoelastic:mainfrom
Closed
Cache ObjectMappers to prevent continual recursion during dynamic mapper building#103858benwtrent wants to merge 3 commits intoelastic:mainfrom
benwtrent wants to merge 3 commits intoelastic:mainfrom
Conversation
Collaborator
|
Pinging @elastic/es-search (Team:Search) |
Collaborator
|
Hi @benwtrent, I've created a changelog YAML for you. |
benwtrent
commented
Jan 3, 2024
Comment on lines
+194
to
+205
| @Override | ||
| public final ObjectMapper build(MapperBuilderContext context) { | ||
| if (objectMapperCache != null) { | ||
| return objectMapperCache; | ||
| } | ||
| objectMapperCache = doBuild(context); | ||
| return objectMapperCache; | ||
| } | ||
|
|
||
| protected void clearObjectMapperCache() { | ||
| objectMapperCache = null; | ||
| } |
Member
Author
Contributor
There was a problem hiding this comment.
Thanks for pinging. I think reverting for now is our wisest option. Happy you have come to a similar conclusion, I think. Long term, we should reconsider what we want to do . Perhaps the updates to the benchmarks is something we do want to get in separately?
Member
Author
There was a problem hiding this comment.
Perhaps the updates to the benchmarks is something we do want to get in separately?
Yes, I will open a separate PR. Its a small adjustment, but showed how we still hadn't addressed the performance issue.
elasticsearchmachine
pushed a commit
that referenced
this pull request
Jan 4, 2024
benwtrent
added a commit
to benwtrent/elasticsearch
that referenced
this pull request
Jan 4, 2024
Reverts elastic#90674 The revert is not perfectly clean as there are some minor adjustments to account for later changes. This is in contrast with: elastic#103858 closes: elastic#103011
benwtrent
added a commit
to benwtrent/elasticsearch
that referenced
this pull request
Jan 4, 2024
Reverts elastic#90674 The revert is not perfectly clean as there are some minor adjustments to account for later changes. This is in contrast with: elastic#103858 closes: elastic#103011
elasticsearchmachine
pushed a commit
that referenced
this pull request
Jan 4, 2024
elasticsearchmachine
pushed a commit
that referenced
this pull request
Jan 4, 2024
This file contains hidden or 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
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.
When building dynamic mappers, it is possible to recurse down the ObjectMapper tree more than once. If the ObjectMapper.Builder keeps rebuilding the objects every time, even if there is no change, the runtime increases significantly.
This commit addresses this by caching the ObjectMapper that is built by the Builder. Invalidating the cache when something is changed.
closes: #103011