From 2fb7f4795e53dddd330f673c727f04c9b1b7c9de Mon Sep 17 00:00:00 2001 From: Sam Caldwell Date: Mon, 13 Jun 2022 14:38:42 -0400 Subject: [PATCH] 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 --- racket/typed/syndicate/proto.rkt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/racket/typed/syndicate/proto.rkt b/racket/typed/syndicate/proto.rkt index 2252379..6a41dbe 100644 --- a/racket/typed/syndicate/proto.rkt +++ b/racket/typed/syndicate/proto.rkt @@ -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)])))