typed: fix performance pathology in role graph compilation

Wasn't checking redundancy in adding states to the worklist, so could
end up analyzing the same state many, many times. RoleNTimes exposed
this behavior: going from 3 to 5 repetitions caused compilation to hang
This commit is contained in:
Sam Caldwell 2022-06-13 14:38:42 -04:00
parent b8d580faf3
commit 2fb7f4795e
1 changed files with 5 additions and 4 deletions

View File

@ -204,13 +204,14 @@
(values D txns)))
(define assertions (assertions-in-state current assertion#))
(define new-work
(for*/list ([txns (in-hash-values transitions)]
(for*/set ([txns (in-hash-values transitions)]
[txn (in-set txns)]
[st (in-value (transition-dest txn))]
#:unless (equal? st current)
#:unless (hash-has-key? states st))
#:unless (or (equal? st current)
(hash-has-key? states st)
(member st more)))
st))
(loop (append more new-work)
(loop (append more (set->list new-work))
(hash-set states current (state current transitions assertions)))]
['()
(role-graph (set (Role-nm role)) states)])))