Skip to content

Conversation

redsun82
Copy link
Contributor

@redsun82 redsun82 commented Jul 27, 2022

In Swift we encountered a situation where ordering of nodes and edges in the control flow graph was not stable between test runs.

This patch:

  • adds the successor string representation to the edge ordering
  • adds an overridable getOrderDisambiguation method to both node and edge orderings

This is used in #9891

This is currently only used in tests.

@redsun82 redsun82 changed the title Control Flow: add more ordering for edges Control Flow: extend ordering for edges Jul 27, 2022
@redsun82 redsun82 marked this pull request as ready for review July 27, 2022 14:54
@redsun82 redsun82 requested review from a team as code owners July 27, 2022 14:54
@redsun82 redsun82 requested a review from nickrolfe July 27, 2022 14:59
@nickrolfe
Copy link
Contributor

Do I understand correctly that you've observed CFG nodes that have two or more successors with the exact same locations and the same SuccessorType, but are distinguished by their toString()?

nickrolfe
nickrolfe previously approved these changes Jul 27, 2022
Copy link
Contributor

@nickrolfe nickrolfe left a comment

Choose a reason for hiding this comment

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

Either way, the change looks fine, and I can see for all three languages it's only used by the CFG tests, so I don't think we need a change note.

@nickrolfe nickrolfe added the no-change-note-required This PR does not need a change note label Jul 27, 2022
@redsun82
Copy link
Contributor Author

I was seeing flakiness in these lines on a branch of mine

# 141| case ...
#-----| -> =~ ...
# 141| 0
#-----| -> =~ ...
# 141| =~ ...
#-----| -> 0
# 141| =~ ...
#-----| no-match -> =~ ...
#-----| match -> true
# 141| 1
#-----| -> =~ ...
# 141| =~ ...
#-----| -> 1
# 141| =~ ...
#-----| match -> true
#-----| no-match -> case ...
with the successors changing order betwen runs. This change seemed to help, but now I have started seeing flakiness again, although this time it might rather be related to graph node ordering. I see an alternation between

#  141| =~ ...
#-----|  -> 0

#  141| =~ ...
#-----| no-match -> =~ ...
#-----| match -> true

#  141| 1
#-----|  -> =~ ...

#  141| =~ ...
#-----|  -> 1

#  141| =~ ...
#-----| match -> true
#-----| no-match -> case ...

and

#  141| =~ ...
#-----| no-match -> =~ ...
#-----| match -> true

#  141| =~ ...
#-----|  -> 0

#  141| 1
#-----|  -> =~ ...

#  141| =~ ...
#-----| match -> true
#-----| no-match -> case ...

#  141| =~ ...
#-----|  -> 1

I'll research this a bit more maybe before merging this

@nickrolfe
Copy link
Contributor

It looks like you have multiple nodes at line 141 (with the same start/end line/column) that all have =~ ... as their toString() result. So I'm not surprised you're seeing flakiness - they are equal for all the order by expressions in the nodes predicate.

michaelnebel
michaelnebel previously approved these changes Jul 28, 2022
Copy link
Contributor

@michaelnebel michaelnebel left a comment

Choose a reason for hiding this comment

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

LGTM!

@redsun82 redsun82 dismissed stale reviews from michaelnebel and nickrolfe via 9b26921 July 28, 2022 07:11
@redsun82 redsun82 changed the title Control Flow: extend ordering for edges Control Flow: extend ordering Jul 28, 2022
@redsun82
Copy link
Contributor Author

As the edge ordering was not enough to solve the flakiness I had, I added a further customizable string key. In #9891 I use it with getPrimaryQlClasses which seems to finally solve my flakiness issues.

Copy link
Contributor

@michaelnebel michaelnebel left a comment

Choose a reason for hiding this comment

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

LGTM

@redsun82 redsun82 merged commit e43755b into main Jul 28, 2022
@redsun82 redsun82 deleted the redsun82/cfg-order branch July 28, 2022 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C# no-change-note-required This PR does not need a change note Ruby Swift
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants