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

Go: Stratify CFG::succ to avoid recursion #15162

Merged
merged 7 commits into from Jan 4, 2024

Conversation

owen-mc
Copy link
Contributor

@owen-mc owen-mc commented Dec 19, 2023

The first level doesn't deal with defer statements properly. The second level uses the first level to deal with them properly.

@owen-mc owen-mc added the no-change-note-required This PR does not need a change note label Dec 19, 2023
@owen-mc owen-mc requested a review from a team as a code owner December 19, 2023 15:41
@github-actions github-actions bot added the Go label Dec 19, 2023
@owen-mc
Copy link
Contributor Author

owen-mc commented Dec 19, 2023

Happy to take suggestions for a better name to replace succSimple for the first layer. Also, now that I think about it, it should probably be private, shouldn't it? I'm quite drawn by the idea of succ0 and succ1, both private, and then a public succ which is an alias for succ1, as this gives a framework for stratifying succ more generally. But maybe that's over the top.

The first level doesn't deal with defer statements properly.
The second level usees the first level to deal with them properly.
@owen-mc
Copy link
Contributor Author

owen-mc commented Dec 20, 2023

Performance testing shows no change on the normal set of repos but a big speedup on the two repos that we noticed the original performance problem on: analysis time went from 1304s to 298s on one and 950s to 228s on the other. I don't think we need a full QA run, but I can do one if requested.

@@ -2074,6 +2080,12 @@ module CFG {
)
}

/** Gets a successor of `nd`, that is, a node that is executed after `nd`. */
Copy link
Contributor

Choose a reason for hiding this comment

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

Mention what the Simple variant omits

go/ql/lib/semmle/go/controlflow/ControlFlowGraphImpl.qll Outdated Show resolved Hide resolved
Copy link
Contributor

@smowton smowton left a comment

Choose a reason for hiding this comment

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

Indeed there's no need for the private top-level predicate to be cached. As part of a recursive definition along with the member succ0s it should also be nomagic because context from succ including nextDefer etc is harmful to introduce anywhere in the recursion.

go/ql/lib/semmle/go/controlflow/ControlFlowGraphImpl.qll Outdated Show resolved Hide resolved
Copy link
Contributor

@smowton smowton left a comment

Choose a reason for hiding this comment

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

DCA to check the magic changes haven't had any untoward side-effects; then LGTM

@owen-mc
Copy link
Contributor Author

owen-mc commented Jan 4, 2024

DCA shows no change in performance for the normal repos and the expected speed-ups for the two affected repos (maybe even slightly better - because of to nomagic possibly?).

@owen-mc owen-mc merged commit 6f9242b into github:main Jan 4, 2024
13 checks passed
@owen-mc owen-mc deleted the go/stratify-cfg-succ branch January 4, 2024 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Go no-change-note-required This PR does not need a change note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants