\documentclass{beamer}
\usepackage{listings}
\usepackage{ulem}
\usepackage{lmodern}
\usepackage[T1]{fontenc}

\title{Iteratees in C}
\subtitle{the lightning talk}

\author{pesco \texttt{\color{gray}@khjk.org}}
\date{30C3, Hamburg, 27-30.12.2013}

\begin{document}
\begin{frame}\titlepage\end{frame}

%=====
\begin{frame}{Wat?}
\begin{itemize}
\item Iteratees are \emph{stream processors}.
\item Programming model / API
  \begin{itemize}
  \item to allow reasoning about I/O
  \end{itemize}
\item Origin: functional programming
\item Challenge: Do it without first-class functions!
  \begin{itemize}
  \item cf. Hammer
  \end{itemize}
\end{itemize}
\end{frame}

%=====
\begin{frame}{Security}
\begin{itemize}
\item High level
\item ``Declarative''
\item Be formal about accepted input
\item Modular: reduce unmapped interactions
\end{itemize}

\begin{itemize}
\item[$\Rightarrow$] Avoid weird machines
\item Cf. langsec
\end{itemize}
\end{frame}

%=====
\begin{frame}[fragile]{Case Study: Word Count}
\begin{semiverbatim}
Iteratee word_ = \alert<3>{bind_}(\alert<2>{dropws}, \alert<2>{dropword});
Iteratee countwords = \alert<3>{wrap}(\alert<3>{decode}(word_), \alert<2>{count});

Iteratee it = \alert<3>{apply}(\alert<3>{enumf}(stdin), countwords);
uintptr_t nwords = (uintptr_t)\alert<3>{finish}(it);
\end{semiverbatim}
\end{frame}

%=====
\begin{frame}{Benchmark}
\begin{itemize}
\item "rockyou" password list 
  \begin{itemize}
  \item 14.344.392 lines
  \item \textasciitilde{}14.44M words
  \end{itemize}
\end{itemize}

\begin{itemize}
\item \texttt{wc -w}
  \begin{itemize}
  \item 3.8s real 3.6s user 0.1s sys
  \item ignores non-ASCII
  \end{itemize}
\end{itemize}

\begin{itemize}
\item \texttt{./iter} (\texttt{main} = \texttt{test4})
  \begin{itemize}
  \item \sout{9.2s real 8.5s user 0.7s sys}
  \item 3.7s real 3.6s user 0.1s sys
  \item total allocation: 600MB (over whole runtime)
  \item peak memory use: 3MB (concurrent)
  \end{itemize}
\end{itemize}
\end{frame}

%=====
\begin{frame}{PoC Implementation}
\begin{itemize}
\item Basic iteratees
\item Input from file descriptor
\item ``\texttt{decode}'' combinator
\item UTF-8 decoder
\item Several simple test examples
  \begin{itemize}
  \item word count, line count, UTF-8 character count, \dots
  \end{itemize}
\end{itemize}

\begin{itemize}
\item Automatic memory management
  \begin{itemize}
  \item uses standard \texttt{malloc}/\texttt{free} for arenas
  \item x86 (32-bit) only right now (needs to know registers)
  \end{itemize}
\end{itemize}

\begin{itemize}
\item \textasciitilde{}1500 lines alltogether
\end{itemize}
\end{frame}

%=====
\begin{frame}{Future Work}
\begin{itemize}
\item More memory management options
\item A larger case study
\item Flesh out a proper library/API
\item Recursive-descent parser combinators
\item Iteratee API for Hammer
\item \dots
\end{itemize}
\end{frame}

%=====
\begin{frame}{Pointers}
\begin{itemize}
\item PoC repo: \alert{\texttt{http://code.khjk.org/citer/}}
  \begin{itemize}
  \item code
  \item slides
  \item slides (30min talk)
  \end{itemize}
\end{itemize}

\begin{itemize}
\item Feedback: \alert{\texttt{pesco\,@\,khjk.org}}
\end{itemize}
\end{frame}

\end{document}
