Skip to content
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

C++: Further performance improvement for the null termination queries #7018

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Labels
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
@geoffw0
Copy link
Contributor

@geoffw0 geoffw0 commented Nov 1, 2021

Follow-up to #6915.

The goal here was to eliminate the mutual recursion between mayAddNullTerminator and mayAddNullTerminatorHelper, which was still causing unnecessarily slow performance on a few projects. I'm not sure if I've found the best solution to this - in particular mayAddNullTerminatorHelper looks quite large to me, though I haven't seen it blow up in practice. Happy to take further suggestions.

The change has a small positive effect on performance locally. I ran DCA on this (actually a variant with the two queries enabled) and only saw a 29s overall improvement there, which is likely not statistically significant.

@MathiasVP

@geoffw0 geoffw0 added the C++ label Nov 1, 2021
@geoffw0 geoffw0 requested a review from as a code owner Nov 1, 2021
Copy link
Contributor

@MathiasVP MathiasVP left a comment

LGTM (with the exception of a small QLDoc nitpick).

mayAddNullTerminatorHelper(e, va, v0) and
mayAddNullTerminator(pragma[only_bind_into](e0), pragma[only_bind_into](v0.getAnAccess())) and
Copy link
Contributor

@MathiasVP MathiasVP Nov 2, 2021

Ah, I see why this speeds it up. Previously, we were computing an SCC consisting of {mayAddNullTerminator, mayAddNullTerminatorHelper}, but now we're computing mayAddNullTerminatorHelper first, and then evaluating an SCC just containing mayAddNullTerminator. So this doesn't change any query results. Is that a correct description of what's going on?

Copy link
Contributor Author

@geoffw0 geoffw0 Nov 2, 2021

Yes, that's my understanding as well. The tricky part is that we may be computing a bigger (less constrained) mayAddNullTerminatorHelper relation in the first place, but I haven't seen that be a problem.

cpp/ql/lib/semmle/code/cpp/commons/NullTermination.qll Outdated Show resolved Hide resolved
Co-authored-by: Mathias Vorreiter Pedersen <mathiasvp@github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment