Skip to content

Commit ef92186

Browse files
committed
Pictures + Restructure
1 parent b98c10e commit ef92186

File tree

6 files changed

+131
-41
lines changed

6 files changed

+131
-41
lines changed

enq-deq-equiv/notes.pdf

27.4 KB
Binary file not shown.

enq-deq-equiv/notes.tex

Lines changed: 112 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@
7676
\DeclareMathOperator{\tzprepush}{z^{\prime}_{\mathrm{pre-push}}}
7777
\DeclareMathOperator{\tzprepop}{z^{\prime}_{\mathrm{pre-pop}}}
7878
\DeclareMathOperator{\tzpostpop}{z^{\prime}_{\mathrm{post-pop}}}
79+
\DeclareMathOperator{\cinit}{c_{\text{init}}}
80+
\DeclareMathOperator{\emt}{\mathrm{empty}}
7981

8082
% theorems
8183
\newtheorem{thm}{Theorem}[section]
@@ -155,7 +157,7 @@
155157

156158
\reqnomode
157159

158-
\textbf{Disclaimer}: we assume familiarity with citeOG, adopt its notational conventions, and steal its definitions!
160+
\textbf{Disclaimer}: we assume familiarity with \cite{OG}, adopt its notational conventions, and steal its definitions!
159161

160162
Further, we work with a specific subset of \emph{Rio}, denoted $\Rio$, namely
161163
\begin{align*}
@@ -230,6 +232,44 @@ \section{Structure and Semantics of Rio Trees}
230232
% For $t \in \CTopo$ with $t \to t^\prime$, we'll occasionally use $t$ when we really mean the topology of the same shape, $t^\prime$.
231233
% \end{abuse}
232234

235+
\begin{figure}[!htb]
236+
\centering
237+
\begin{subfigure}[t]{0.49\linewidth}
238+
\centering
239+
\begin{tikzpicture}[scale = 1.25]
240+
\node[draw, align=left] at (-1,-1.3) {$A_1$};
241+
\node[align=left] at (-1.55,-1.3) {$A$};
242+
\node[draw, align=left] at (0,-2.3) {$B_2, B_1$};
243+
\node[align=left] at (-0.85,-2.3) {$B$};
244+
\node[draw, align=left] at (2,-2.3) {$C_1$};
245+
\node[align=left] at (1.45,-2.3) {$C$};
246+
247+
\draw (0,0) -- (-1, -1);
248+
\draw (0,0) -- (1, -1);
249+
\draw (1,-1) -- (0, -2);
250+
\draw (1,-1) -- (2, -2);
251+
\end{tikzpicture}
252+
\caption{Over topology $\Node(\ast, \Node(\ast, \ast))$}
253+
\end{subfigure}
254+
\begin{subfigure}[t]{0.49\linewidth}
255+
\centering
256+
\begin{tikzpicture}[scale = 1.25]
257+
\node[draw, align=left] at (-1,-1.3) {$A_1$};
258+
\node[draw, align=left] at (0,-1.3) {$B_1$};
259+
\node[draw, align=left] at (1,-1.3) {\phantom{$C_1$}};
260+
\node[align=left] at (-1,-1.8) {$A$};
261+
\node[align=left] at (0,-1.8) {$B$};
262+
\node[align=left] at (1,-1.8) {$C$};
263+
264+
\draw (0,0) -- (-1, -1);
265+
\draw (0,0) -- (0, -1);
266+
\draw (0,0) -- (1, -1);
267+
\end{tikzpicture}
268+
\caption{Over topology $\Node(\ast, \ast, \ast)$}
269+
\end{subfigure}
270+
\caption{Rio trees decorated by classes $A$, $B$, and $C$}
271+
\end{figure}
272+
233273
\begin{dfn}
234274
For topology $t \in \Topo$, the set $\RioTree(t)$ of \emph{Rio trees} over $t$ is defined by
235275
\begin{align*}
@@ -256,12 +296,13 @@ \section{Structure and Semantics of Rio Trees}
256296
\inference{}
257297
{
258298
ts \in \Topo^n\\
259-
rs \in \Rk^{n}\\
299+
rs \in \Rk^{n}\\\\
300+
\forall 1 \leq i < j \leq n. \; rs[i] \neq rs[j]\\
260301
\forall 1 \leq i \leq n. \; os[i] \in \OrdTree(ts[i])
261302
}
262303
{\Internal(rs, os) \in \OrdTree(\Node(ts))}
263304
\end{align*}
264-
These are trees with each internal node's child given a rank, thereby inducing a total ordering of children.
305+
These are trees with each internal node's child given a \emph{unique} rank, thereby inducing a total ordering of children.
265306
\end{dfn}
266307

267308
Let $\flow : \Pkt \to \Class$ be an opaque mapping from packets to the class they belong to (flow inference).
@@ -300,17 +341,27 @@ \section{Structure and Semantics of Rio Trees}
300341
&&
301342
\inference{}
302343
{
303-
\exists 1 \leq i \leq |qs|. \; \pop(qs[i], os[i]) = (\pkt, q)\\
344+
\pop(qs[i], os[i]) = (\pkt, q)\\\\
304345
\forall 1 \leq j \leq |qs|. \; j \neq i \land \pop(qs[j], os[j]) = (\pkt^\prime, q^\prime) \implies rs[i] < rs[j]
305346
}
306347
{\pop(\Internal(qs), \Internal(rs, os)) = (\pkt, \Internal(qs[q/i]))}
307348
\end{align*}
308349
Informally, we recursively pop the smallest ranked, poppable subtree.
309350
\end{dfn}
310351

311-
\newpage
352+
\section{Modelling Scheduling Algorithms}
353+
354+
Like \cite{OG}, we model scheduling algorithms through a \emph{control}, a thin-layer over the tree policies run on.
355+
They keep track of
356+
\begin{enumerate}
357+
\item a state from a fixed collection $\St$
358+
\item an underlying tree of buffered packets % is buffered the right word?
359+
\item scheduling transactions that update state and construct auxillary structures to push or pop the tree
360+
\end{enumerate}
361+
They come in two flavors: Rio \& PIFO Controls.
362+
The former determines the order to forward packets at dequeue while latter does so at enqueue.
312363

313-
\section{PIFO \& Rio Controls}
364+
\subsection{Controls}
314365

315366
\begin{figure}[!htb]
316367
\begin{align*}
@@ -360,8 +411,6 @@ \section{PIFO \& Rio Controls}
360411
\label{fig:control_push_pop}
361412
\end{figure}
362413

363-
For these notes, we'll refer to \emph{controls} from citeOG as \emph{PIFO controls}.
364-
365414
\begin{dfn}
366415
Let $t \in \Topo$ and \emph{scheduling transactions} $\zprepush$ and $\zpostpop$ be partial functions
367416
\begin{align*}
@@ -370,7 +419,7 @@ \section{PIFO \& Rio Controls}
370419
\end{align*}
371420
Define $\PIFOControl(t, \zprepush, \zpostpop)$ to be the set of quadruples
372421
$$(s, q, \zprepush, \zpostpop)$$
373-
where $s \in \St$ and $q \in \PIFOTree(t)$.
422+
where $s \in \St$ and well-formed $q \in \PIFOTree(t)$.
374423
\end{dfn}
375424

376425
\begin{dfn}
@@ -387,23 +436,44 @@ \section{PIFO \& Rio Controls}
387436

388437
Both controls admit $\push$ and $\pop$ operations:
389438
\begin{align*}
390-
\push &: \PIFOControl(t, \zprepush, \zpostpop) \times \Pkt \to \PIFOControl(t, \zprepush, \zpostpop)\\
391-
\pop &: \PIFOControl(t, \zprepush, \zpostpop) \to \Pkt \times \PIFOControl(t, \zprepush, \zpostpop)\\
392-
\push &: \RioControl(t, \zprepush, \zprepop, \zpostpop) \times \Pkt \to \RioControl(t, \zprepush, \zprepop, \zpostpop)\\
393-
\pop &: \RioControl(t, \zprepush, \zprepop, \zpostpop) \to \Pkt \times \RioControl(t, \zprepush, \zprepop, \zpostpop)
439+
\push &: \PIFOControl(t, \zprepush, \zpostpop) \times \Pkt \halfto \PIFOControl(t, \zprepush, \zpostpop)\\
440+
\pop &: \PIFOControl(t, \zprepush, \zpostpop) \halfto \Pkt \times \PIFOControl(t, \zprepush, \zpostpop)\\
441+
\push &: \RioControl(t, \zprepush, \zprepop, \zpostpop) \times \Pkt \halfto \RioControl(t, \zprepush, \zprepop, \zpostpop)\\
442+
\pop &: \RioControl(t, \zprepush, \zprepop, \zpostpop) \halfto \Pkt \times \RioControl(t, \zprepush, \zprepop, \zpostpop)
394443
\end{align*}
395444

396445
Their semantics are written out in full in \Cref{fig:control_push_pop}.
397446

447+
\subsection{Simulations}
448+
449+
\begin{dfn}
450+
For $t \in \Topo$, define $\emt_t \in \PIFOTree(t)$ such that
451+
\begin{align*}
452+
\inference{}
453+
{p \in \PIFO(\Pkt)\\ \pop(p) \text{ is undefined}}
454+
{\emt_{\ast} = \Leaf(p)}
455+
&&
456+
\inference{}
457+
{
458+
ts \in \Topo^n\\
459+
p \in \PIFO(\{1, \ldots, n\})\\\\
460+
\pop(p) \text{ is undefined}\\
461+
\forall 1 \leq i \leq n. \; qs[i] = \emt{ts[i]}
462+
}
463+
{\emt_{\Node(ts)} = \Internal(p, qs)}
464+
\end{align*}
465+
Informally, $\emt_t$ is a PIFO tree of topology $t$, with empty PIFOs at all nodes.
466+
\end{dfn}
467+
398468
\begin{dfn}
399469
Define the $\to \; \subseteq \PIFOControl(t, \zprepush, \zpostpop) \times \PIFOControl(t, \zprepush, \zpostpop)$ by
400470
\begin{align*}
401471
\inference{}
402-
{\pkt \in \Pkt\\ \push c \pkt = c^\prime}
472+
{\pkt \in \Pkt\\ \push(c, \pkt) = c^\prime}
403473
{c \to c^{\prime}}
404474
&&
405475
\inference{}
406-
{\pop c = (\pkt, c^\prime)}
476+
{\pop(c) = (\pkt, c^\prime)}
407477
{c \to c^{\prime}}
408478
\end{align*}
409479
i.e. $c \to c^\prime$ if $c^\prime$ is a push or pop from $c$.
@@ -414,14 +484,14 @@ \section{PIFO \& Rio Controls}
414484
A partial function
415485
$$
416486
f :
417-
\RioControl(t, \zprepush, \zprepop, \zpostpop)
487+
\PIFOControl(t, \zprepush, \zpostpop)
418488
\halfto
419-
\PIFOControl(t^\prime, \tzprepush, \tzpostpop)
489+
\RioControl(t^\prime, \tzprepush, \tzprepop, \tzpostpop)
420490
$$
421-
is \emph{simulation} if, for all $\pkt \in \Pkt$ and $f(c_1) = c_2$, the following conditions are satisfied:
491+
is \emph{simulation} if the following conditions are satisfied:
422492
\begin{enumerate}
423-
\item There exists $f(c_{\text{init}}) = c^{\prime}_{\text{init}}$ where the trees in $c_{\text{init}}$ and $c^\prime_{\text{init}}$ hold empty PIFOs at the leaves.
424-
\item If $c_{\text{init}} \to^\ast c_1$,
493+
\item There exists $c_{init} = (s, q, \zprepush, \zpostpop)$ where $q = \emt_t$ and $c_{init} \in \operatorname{dom} f$.
494+
\item When $c_{\text{init}} \to^\ast c_1$ and $f(c_1) = c_2$, we can guarantee the following:
425495
\begin{align}
426496
\pop(c_1) \text{ is undefined} &\implies \pop(c_2) \text{ is undefined}\\
427497
\pop(c_1) = (\pkt, c^\prime_1) &\implies \pop(c_2) = (\pkt, c^\prime_2) \land f(c_1^\prime) = c_2^\prime\\
@@ -430,6 +500,7 @@ \section{PIFO \& Rio Controls}
430500
\end{enumerate}
431501
\end{dfn}
432502

503+
433504
\newpage
434505

435506
\section{Enqueue and Dequeue-Side Equivalence}
@@ -441,17 +512,18 @@ \subsection{Round-Robin}
441512
\begin{figure}[!htb]
442513
\centering
443514
\begin{subfigure}[t]{0.49\linewidth}
444-
\lstinputlisting{sched_trans/rio/z_post-pop.pseudo}
445-
\lstinputlisting{sched_trans/rio/z_pre-pop.pseudo}
446-
\lstinputlisting{sched_trans/rio/z_pre_push.pseudo}
447-
\caption{Rio Control}
448-
\end{subfigure}
449-
\begin{subfigure}[t]{0.49\linewidth}
450-
\lstinputlisting{sched_trans/pifo/z_post-pop.pseudo}
451515
\lstinputlisting{sched_trans/pifo/z_pre-push.pseudo}
516+
\lstinputlisting{sched_trans/pifo/z_post-pop.pseudo}
452517
\caption{PIFO Control}
453518
\end{subfigure}
519+
\begin{subfigure}[t]{0.49\linewidth}
520+
\lstinputlisting{sched_trans/rio/z_pre_push.pseudo}
521+
\lstinputlisting{sched_trans/rio/z_pre-pop.pseudo}
522+
\lstinputlisting{sched_trans/rio/z_post-pop.pseudo}
523+
\caption{Rio Control}
524+
\end{subfigure}
454525
\caption{Scheduling Transactions}
526+
\label{fig:sched_trans}
455527
\end{figure}
456528

457529
For $n \in \mathbb N$, let's put our theory to use by constructing PIFO and Rio controls for
@@ -461,15 +533,21 @@ \subsection{Round-Robin}
461533

462534
Both controls use the same underlying topology, namely
463535
$$
464-
t = \Node((\underbrace{\ast, \ast, \ldots, \ast}_{n \text{ times}}))
536+
t = \Node(\underbrace{\ast, \ast, \ldots, \ast}_{n \text{ times}})
465537
$$
466-
Figure \Cref{fig:placeholder} describes the scheduling transactions
467-
468-
469-
470-
and showing they're in simulation.
471-
This would show the equivalence of enqueue and dequeue-side semantics for a specific type of program!
538+
\Cref{fig:sched_trans} describes their scheduling transactions in pseudocode.
539+
Therefore, we have the materials to define
540+
\begin{align*}
541+
\PIFOControl(t, \zprepush, \zpostpop)
542+
&&
543+
\text{and}
544+
&&
545+
\RioControl(t, \tzprepush, \tzprepop, \tzpostpop)
546+
\end{align*}
547+
I.e. the collection of PIFO and Rio controls for our program.
548+
Let's find a simulation between them!
472549

550+
\newpage
473551

474552
\renewcommand\refname{\LARGE References}
475553
\bibliographystyle{alpha}

enq-deq-equiv/refs.bib

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@misc{OG,
2+
title={Formal Abstractions for Packet Scheduling},
3+
author={Anshuman Mohan and Yunhe Liu and Nate Foster and Tobias Kappé and Dexter Kozen},
4+
year={2023},
5+
eprint={2211.11659},
6+
archivePrefix={arXiv},
7+
primaryClass={cs.NI},
8+
url={https://arxiv.org/abs/2211.11659},
9+
}
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
z_post-pop(st, pkt):
1+
def z_post-pop(st, pkt):
22
f = flow(pkt)
3-
i = int(s["turn"])
3+
turn = int(s["turn"])
4+
i = turn
45
while i != f:
56
st["r_" + str(i)] += n
67
i = (i + 1) % n
78
st["turn"] = float((f + 1) % n)
9+
if turn >= st["turn"]:
10+
st["cycle"] += 1
811
return st

enq-deq-equiv/sched_trans/pifo/z_pre-push.pseudo

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
z_pre-push(st, pkt):
1+
def z_pre-push(st, pkt):
22
r = st["counter"]
3-
st["count"] += 1
3+
st["counter"] += 1
44
f = flow(pkt)
55
rank_ptr = "r_" + str(f)
66
r_i = int(st[rank_ptr])
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
def z_pre-push(st, pkt):
2-
r = st["counter"]
3-
st["counter"] += 1
4-
return float_to_int(r)
2+
r = int(st["counter"])
3+
st["counter"] += 1.0
4+
return r

0 commit comments

Comments
 (0)