-
Notifications
You must be signed in to change notification settings - Fork 24.8k
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
Cache ObjectMappers to prevent continual recursion during dynamic mapper building #103858
Cache ObjectMappers to prevent continual recursion during dynamic mapper building #103858
Conversation
Pinging @elastic/es-search (Team:Search) |
Hi @benwtrent, I've created a changelog YAML for you. |
@Override | ||
public final ObjectMapper build(MapperBuilderContext context) { | ||
if (objectMapperCache != null) { | ||
return objectMapperCache; | ||
} | ||
objectMapperCache = doBuild(context); | ||
return objectMapperCache; | ||
} | ||
|
||
protected void clearObjectMapperCache() { | ||
objectMapperCache = null; | ||
} |
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.
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.
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?
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.
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.
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
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
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