-
Notifications
You must be signed in to change notification settings - Fork 228
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
SE: Pass states per stack #7059
base: master
Are you sure you want to change the base?
SE: Pass states per stack #7059
Conversation
f7bb17f
to
74c570e
Compare
9df7ee7
to
4aaae8a
Compare
Kudos, SonarCloud Quality Gate passed! |
Kudos, SonarCloud Quality Gate passed! |
4aaae8a
to
5d8ca51
Compare
Kudos, SonarCloud Quality Gate passed! |
Kudos, SonarCloud Quality Gate passed! |
d71789e
to
067c0fd
Compare
Quality Gate passedKudos, no new issues were introduced! 0 New issues |
Quality Gate failedFailed conditions See analysis details on SonarCloud Catch issues before they fail your Quality Gate with our IDE extension SonarLint |
@@ -28,7 +28,7 @@ public class SymbolicCheck | |||
/// <summary> | |||
/// Stop processing this branch of the exploded graph. There will be no follow up states. | |||
/// </summary> | |||
protected static readonly ProgramState[] EmptyStates = Array.Empty<ProgramState>(); | |||
protected static readonly ProgramStates EmptyStates = new(); |
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.
This should be removed. Accessing the field has value semantics and a copy is created (we see a ldsfld
(copies the value for value types) instead of a ldsflda
(creates a reference to the field) in the generated IL).
We should just new()
as we do in all the other places as well.
5edd38c
to
ae45497
Compare
Quality Gate passedIssues Measures |
Quality Gate failedFailed conditions See analysis details on SonarCloud Catch issues before they fail your Quality Gate with our IDE extension SonarLint |
Part of #6964
ProgramState[]
andSymbolicContext[]
are the main vehicles to branch a state. When processing an ExplodedNode (which contains a single ProgramState) we end up with these states:The engine needs to work with all the cases and so an array is used to represent the branchings. This results in a lot of allocations of small arrays (1 or 2 elements) on the heap. This PR replaces the array with a struct which is optimized for the 0, 1, and 2 elements cases. It passes the states on the stack. It needs to reserve three pointers on the stack to do so (this increases the stack space used. The array needed a single pointer on the stack). The three pointers are used for
The result is a reduction in allocation in total by ~5%. It eliminates
SymbolicContext[]
usage entirely (down to 0from 17.820) and reduces the allocation count by 35.000.
SymbolicContext[]
was the fourth most allocated object before.The benefit (reduced GC pressure) comes at the cost of more expensive method calls (more stack space, more data transferred in a call). Because of this, a runtime performance measurement needs to be done before merging the PR.
As a result of this change, the distinguishing between IMultiProcessor and ISimpleProcessor can be resolved. There is also no need to distinguish between PreProcess and PreProcessSimple (same for Post of course) in SymbolicCheck anymore. Both changes simplify the usage of the engine.