C#: Improve performance of type conversion library#279
C#: Improve performance of type conversion library#279semmle-qlci merged 2 commits intogithub:masterfrom
Conversation
calumgrant
left a comment
There was a problem hiding this comment.
Great stuff. Some very trivial comments.
| * ``` | ||
| * but performance is improved by explicitly evaluating the `i`th argument | ||
| * only when all preceding arguments are convertible. | ||
| private Type getTypeArgumentRanked(UnboundGenericType ugt, IdentityConvertibleConstructedType t, int i) { |
There was a problem hiding this comment.
A doc comment would be much appreciated here.
| exists(int j | | ||
| fromTypeArgument = getTypeArgumentRanked(_, _, i) and | ||
| toTypeArgument = getTypeArgumentRanked(_, _, j) and | ||
| i <= j and j <= i |
There was a problem hiding this comment.
Why was j introduced? (I guess it's an optimizer workaround but is it still needed, and what's it doing?) Perhaps a doc and raise a ticket?
There was a problem hiding this comment.
Yes, to avoid the optimizer joining on i.
| } | ||
|
|
||
| pragma[nomagic] | ||
| private predicate convIdentityMultiple01Aux0(UnboundGenericType ugt, IdentityConvertibleConstructedType toType, TypeArgument fromTypeArgument0, TypeArgument toTypeArgument0, TypeArgument toTypeArgument1) { |
There was a problem hiding this comment.
Here, and elsewhere - max line width exceeded - sorry! But, would probably read more clearly.
There was a problem hiding this comment.
Is it ok to let the QL autoformatter handle this? I believe we should have that quite soon.
| */ | ||
| pragma[nomagic] | ||
| private predicate convTypeArguments(TypeArgument fromTypeArgument, TypeArgument toTypeArgument, int i, TVariance v) { | ||
| exists(int j | |
There was a problem hiding this comment.
Why introduce j for i (same as previous question)
…te-name-matching PS: Add predicates for case insensitive name matching on `Attribute`s
This PR applies the trick from Java's subtype implementation, namely to special case on the first two type arguments in constructed types.
For smaller snapshots, performance is mostly unchanged, but for huge snapshots it can make a big difference: For example, on an 8 MLoC customer database, the time it takes to construct the type conversion relation is reduced from ~40 minutes to ~4.5 minutes.
@calum