Skip to content

Conversation

@hvitved
Copy link
Contributor

@hvitved hvitved commented Aug 13, 2020

This reduces the size of the commonSubType predicates as we only compute them for relevant DataFlowTypes.

The CSharp-Differences job is here, and it shows a significant performance improvement on dotnet/efcore. Since the predicates affected by this change are cached, the impact of this PR can be seen by focusing on the performance numbers for API Abuse/DisposeNotCalledOnException.ql, as this happens to be the query that evaluates the cached stage.

@hvitved hvitved added the C# label Aug 13, 2020
@hvitved hvitved marked this pull request as ready for review August 14, 2020 08:25
@hvitved hvitved requested a review from a team as a code owner August 14, 2020 08:25
@adityasharad adityasharad changed the base branch from master to main August 14, 2020 18:33
exists(Gvn::GvnType t |
Gvn::unifiable(t1, t) and
commonSubType(t, t2)
commonSubTypeGeneral(t, t2)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a general comment here: a lot of these annotations seem to be working around actual/supposed compiler missteps. For example, here one might more naturally use commonSubType, but pragma[nomagic] suggests that there has been a compilation problem that is being worked around. This leads to the code being more verbose and split up in slightly unnatural ways. Is there a better way to document what's being worked around, or should I simply continue to "filter out" all of these pragmas in my mind?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, here we can't use commonSubType, because we need the more general variant where the first column is not restricted to DataFlowType (but the more general DataFlowTypeOrUnifiable type).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As yes of course.


predicate readStep = readStepImpl/3;

/**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the difference between DataFlowType and Gvn::GvnType. Gvn::GvnType has the following comment on it, which is pretty much the same as the one on DataFlowType.

A global value number for a type. Two types have the same GVN when they
are structurally equal modulo type parameters and identity conversions.
For example, `Func<T, int>` and `Func<S, int>` have the same GVN, but
`Func<T, int>` and `Func<string, int>` do not.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DataFlowType is simply a subset of Gvn::GvnType; namely those that are the result of NodeImpl::getDataFlowType(). I decided to make the QL doc for DataFlowType a bit more data-flow centric, compared to the QL doc for the more generally applicable Gvn::GvnType.

Copy link
Contributor

@calumgrant calumgrant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Tom, this is a really nice speedup.

exists(Gvn::GvnType t |
Gvn::unifiable(t1, t) and
commonSubType(t, t2)
commonSubTypeGeneral(t, t2)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As yes of course.

@calumgrant calumgrant merged commit a93a84f into github:main Aug 21, 2020
@hvitved hvitved deleted the csharp/dataflow-type-restriction branch August 21, 2020 10:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants