Echo cancellation for prospect-monolithic. Still deciding how best to address incremental variant.

This commit is contained in:
Tony Garnock-Jones 2016-02-07 19:32:38 -05:00
parent 1b05122db4
commit fd7dc03dc6
3 changed files with 24 additions and 9 deletions

View File

@ -410,12 +410,13 @@
(define (deliver-scns w new-mux acting-label s aggregate-assertions)
(define old-mux (network-mux w))
(define old-echo-cancelled-assertions (echo-cancelled-routing-table old-mux))
(define-values (scns meta-action)
(compute-scns old-mux new-mux acting-label s aggregate-assertions))
(transition (for/fold [(w (struct-copy network w [mux new-mux]))]
[(entry (in-list scns))]
(match-define (cons label (and event (scn new-assertions))) entry)
(if (equal? (biased-intersection (mux-routing-table old-mux)
(if (equal? (biased-intersection old-echo-cancelled-assertions
(mux-interests-of old-mux label))
new-assertions)
w

View File

@ -1,16 +1,16 @@
#lang prospect-monolithic
;; Demonstrates a (hopefully soon historical!) bug in Syndicate.
;; Test case for a historical bug in Syndicate.
;;
;; When the bug exists, this program receives four SCN events in
;; When the bug existed, this program receiveed four SCN events in
;; total, whereas it should receive only two.
;;
;; While metamessages are "echo cancelled", and receivers only ever
;; get one copy of a sent metamessage no matter how many metas there
;; are, state changes are not (yet). Issuing a quick enough "pulse" of
;; metaassertion while maintaining interest in it leads to an "echo":
;; While metamessages were "echo cancelled", and receivers only ever
;; got one copy of a sent metamessage no matter how many metas there
;; were, state changes were not. Issuing a quick enough "pulse" of
;; metaassertion while maintaining interest in it led to an "echo":
;; multiple receipts of the pulse.
;;
;; The fix is to adjust the implementation of state change
;; The fix was to adjust the implementation of state change
;; notifications to cancel the echo for metaassertions.
(require prospect/pretty)

View File

@ -9,6 +9,7 @@
mux-update-stream
mux-route-message
mux-interests-of
echo-cancelled-routing-table
compute-scns
compute-affected-pids
pretty-print-mux)
@ -65,14 +66,27 @@
new-scn ;; unnecessary?
aggregate-assertions))
(define at-meta-everything (pattern->trie #t (at-meta ?)))
(define only-meta (datum-tset 'meta))
(define (echo-cancelled-routing-table m)
(trie-subtract (mux-routing-table m)
at-meta-everything
#:combiner (lambda (v1 v2)
(if (tset-member? v1 'meta)
only-meta
#f))))
(define (compute-scns old-m new-m label s aggregate-assertions)
(define old-routing-table (mux-routing-table old-m))
(define new-routing-table (mux-routing-table new-m))
(define echo-cancelled-assertions (echo-cancelled-routing-table new-m))
(define affected-pids
(let ((pids (compute-affected-pids old-routing-table aggregate-assertions))) ;; hmm
(tset-remove (tset-add pids label) 'meta))) ;; TODO: removing meta is weird
(values (for/list [(pid (tset->list affected-pids))]
(cons pid (scn (biased-intersection new-routing-table (mux-interests-of new-m pid)))))
(cons pid (scn (biased-intersection echo-cancelled-assertions
(mux-interests-of new-m pid)))))
(and (not (meta-label? label))
(drop-scn (scn (trie-relabel new-routing-table
(lambda (v)