-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Java: Improve several join-orders #20088
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
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.
Pull Request Overview
This pull request optimizes join-order performance in Java CodeQL queries by refactoring several predicates to improve query execution efficiency. The changes were identified through join-order badness metrics and focus on reducing intermediate result set sizes during query evaluation.
Key changes include:
- Restructuring generic type parameter substitution logic to join on multiple columns simultaneously
- Reordering type declaration and supertype traversal operations for better join selectivity
- Adding binding constraints and inline pragmas to ensure proper predicate evaluation order
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
File | Description |
---|---|
java/ql/src/Likely Bugs/Collections/ContainsTypeMismatch.ql | Reorders getSourceDeclaration() and getASourceSupertype*() calls to improve join performance |
java/ql/lib/semmle/code/java/Type.qll | Adds binding constraints and inline_late pragmas to haveIntersection predicate with helper predicate |
java/ql/lib/semmle/code/java/Generics.qll | Extracts unificationTargetsParameterized predicate and refactors hasParameterSubstitution to join on multiple columns |
Comments suppressed due to low confidence (1)
java/ql/lib/semmle/code/java/Type.qll:1275
- [nitpick] The predicate name 'erasedHaveIntersectionFilter' is unclear about its purpose. Consider renaming to 'erasedHaveIntersectionBound' or 'erasedHaveIntersectionConstrained' to better reflect that it's a binding-constrained wrapper around erasedHaveIntersection.
private predicate erasedHaveIntersectionFilter(RefType t1, RefType t2) {
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.
Looks plausible to me!
Dca looks good. |
These were all identified by the join-order badness metric and relate to the mass inclusion of quality queries (see #19799 (comment))
Commit 1: For
Generics::hasParameterSubstitution
the join after the delta is much improved if we join on both columns at the same time.Before:
After:
Commit 2:
getSourceDeclaration
and the TC ofgetASourceSuperType
commute, and switching them yields a much better join order in these two cases.Before:
After:
Before:
After:
Commit 3: The inlined
haveIntersection
really needs both arguments bound in order to perform properly - hence why it's inlined. With a bindingset and inline_late we can actually ensure this.Before:
After (now inlined into
potentiallyConfusingTypes
):