-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Make Compiler cache to soft value reference to reduce metaspace oom #15237
Conversation
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.
Make Compiler cache to soft value reference to reduce metaspace oom
Trino caches do not use soft references, to avoid "invalidation storm" when system would otherwise OOM.
Instead, the system needs to be configured so that it doesn't OOM at all.
Also, if we really want to change this direction -- first make sure we want, which I personally doubt -- and start using soft references for all the caches, the change should focus on ensuring that all new caches are soft. I.e. please think about how to automatically ensure that. Modernizer may be helpful here, or some other code analysis.
Also, there are no guarantees for when soft references are freed other than before OOM. This can cause performance to be very variable. That said, I see how cache size based on the number of elements can cause issues since the elements have variable lengths. |
good point This is also visible in #15232 description where singled out entry is 1/3 in size of the average
let's do that -- unless we know that cc @dain for function & expression execution |
Thanks to @findepi @lukasz-stec for discussion and related ideas. Limit the cache by bytes used |
If we use |
@zhangminglei apologies for the delay in responding. I think the easiest way is to modify public static long getBytecodeSize(Class<?> clazz)
{
if (clazz.getClassLoader() instanceof DynamicClassLoader loader) {
return loader.getDefinedClassesBytecodeSize();
}
throw new IllegalArgumentException("Invalid class loader [%s] for %s".formatted(clazz.getClassLoader(), clazz));
} |
do we assume |
👋 @zhangminglei - this PR has become inactive. We hope you are still interested in working on it. Please let us know, and we can try to get reviewers to help with that. We're working on closing out old and inactive PRs, so if you're too busy or this has too many merge conflicts to be worth picking back up, we'll be making another pass to close it out in a few weeks. |
This pull request has gone a while without any activity. Tagging the Trino developer relations team: @bitsondatadev @colebow @mosabua |
We can close this, as the cache weigher approach discussed above is a better direction. |
Description
This PR can reduces metaspace oom issues, make some compiler that use guava cache value from strong reference to soft reference without obvious performance regression under 18,110 production queries.
Fixes #15232
Additional context and related issues
Release notes
( ) This is not user-visible or docs only and no release notes are required.
( ) Release notes are required, please propose a release note for me.
( ) Release notes are required, with the following suggested text: