\documentclass{beamer}
\usepackage{listings}

\usepackage{tikz}
\usetikzlibrary{shapes,arrows,positioning}

\usetheme{Dresden}
\title[Blobsets]{Blobsets}
\author{Emery}

\begin{document}

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

\begin{frame}{Motivation}
Hierarchical storage is a poor abstraction for data with rich context
\pause
\\Hierarchy is weak metadata
\pause
\\Data at rest accumulates contextual metadata
\end{frame}

\begin{frame}{UNIX / Plan 9 file-system}
\begin{itemize}
\pause \item Ergonomic, intuitive
\pause \item Stable semantics
\pause \item Optimized
\pause \item Multipurpose - bulk storage, configuration, system state, UEFI variables
\pause \item Archaic sharing model
\pause \item Migration can be messy
\pause \item SPOF
\end{itemize}
\end{frame}

\begin{frame}{IPFS}
\begin{itemize}
\pause \item Content addressed
\pause \item Explicit namespacing
\pause \item Distributed
\pause \item Global network state - DHT
\pause \item LevelDB
\pause \item Super daemon
\pause \item Extensible
\end{itemize}
\end{frame}

\begin{frame}{DAT}
\begin{itemize}
\pause \item Javascript
\end{itemize}
\end{frame}

\begin{frame}{An alternative approach}
Metadata is too rich for the storage layer\\
\begin{itemize}
\pause \item Storage without implicit structure
\pause \item Fixed, non-negotiable specification
\pause \item Deterministic, transactional updates
\pause \item Multiple least-privileged components
\pause \item Replication
\pause \item Network optional
\end{itemize}
\end{frame}

\section{Blobsets}

\begin{frame}{Just a hash map}
\pause
Blobs may be data of any lengths identified by a 256 bit hash.
\\~\
\pause

Sets are collections of blobs indexed by 64 bit keys.
\\~\
\pause

Keys may be derived from a hash function.
\\~\
\pause

Set may contain the same blob under different keys.
\\~\
\pause

Sets are not recursive.
\end{frame}

\begin{frame}{Implementation}

A set is a hash array mapped trie
\\~\
\pause

Set serialization is CBOR
\\~\
\pause

Blob hash function is a BLAKE2B-256 tree hash with 64 KiB leaves
\\~\
\pause

Key hash function is SipHash
\\~\
\pause

Approximately 1 KLOC of Nim
\\~\

\end{frame}{}

\begin{frame}{BlobStore API}
\pause
\begin{block}{\lstinline{openBlobStream(BlobStore, BlobHash) -> BlobStream}}
	\lstinline{get_pos(BlobStream) -> Integer}

	\lstinline{set_pos(BlobStream, Integer)}

	\lstinline{read(BlobStream, Integer) -> String}

	\lstinline{close(BlobStream)}
\end{block}
\begin{block}{\lstinline{openIngestStream(BlobStore store) -> IngestStream}}
	\lstinline{write(IngestStream, String)}

	\lstinline{finish(IngestStream) -> BlobHash}

	\lstinline{cancel(IngestStream)}

\end{block}

\begin{block}{\lstinline{close(BlobStore store)}}
\end{block}

\end{frame}

\begin{frame}{BlobSet API}
\lstinline{load(BlobStore, BlobHash) -> BlobSet}
\\~\

\lstinline{insert(BlobStore, BlobSet, Key, BlobHash) -> BlobSet}
\\~\

\lstinline{remove(BlobStore, BlobSet, Key) -> BlobSet}
\\~\

\lstinline{union(BlobStore, BlobSet, BlobSet) -> BlobSet}
\\~\

\lstinline{apply(BlobStore, BlobSet, Key, Procedure)}
\\~\

\lstinline{randomApply(BlobStore, BlobSet, Procedure)}
\\~\

\lstinline{commit(BlobStore, BlobSet) -> BlobSet}
\end{frame}

\section{Demo}
\begin{frame}{}
\center{REPL DEMO}
\end{frame}

\section{Audio player}
\begin{frame}{Music Problem}
\begin{itemize}
\pause \item New operating system architecture
\pause \item Restricted access to audio hardware
\pause \item Audio player must be isolated
\pause \item Native audio player has no GUI or CLI
\pause \item Context, not files
\end{itemize}
\end{frame}

\begin{frame}{}
\tikzstyle{block} = [draw, rectangle, minimum height=3em, minimum width=3em]
\tikzstyle{virtual} = [coordinate]
\begin{tikzpicture}[>=stealth,auto, node distance=1cm]
    % Place nodes
    \node [block] (playlist) {XSPF playlist};
    \node [block, left=of playlist, xshift=-8ex] (ext2) {EXT2};
    \node [block, above=of playlist] (audioplayer) {audio player};
    \node [block, above=of ext2] (blob_fs) {synthetic blob file-system};
    \node [block, below=of playlist] (vm) {VM};
    \node [block, below=of ext2] (blob_http) {blob HTTP service};

    % Connect nodes
    \draw [->] (blob_fs) -- node {} (ext2);
    \draw [->] (blob_http) -- node {} (ext2);
    \draw [->] (audioplayer) -- node {} (blob_fs);
    \draw [->] (vm) -- node {} (blob_http);
    \draw [->] (audioplayer) -- node {} (playlist);
    \draw [->] (vm) -- node {} (playlist);
\end{tikzpicture}
\end{frame}

\begin{frame}{MusicBrainz}
	\includegraphics[height=.8\textheight,keepaspectratio]{ngs.png}
\end{frame}

\begin{frame}{MusicBrainz}

\begin{block}
{\url{https://musicbrainz.org/recording/7053937d-45b0-4303-ace7-0db8586821bf}}
\end{block}

\begin{block}
{\url{https://musicbrainz.org/recording/7a677b2a-0a3b-4f62-a1fb-1385ed5c743a}}
\end{block}

\begin{block}
{\url{https://musicbrainz.org/recording/20ff3e70-f7af-4417-b187-0935c526aebc}}
\end{block}

\begin{block}
{\url{http://musicbrainz.org/recording/7dd9713e-0515-4011-937d-969c3a445182}}
\end{block}

\begin{block}
{\url{https://musicbrainz.org/release/76f203a1-e7f4-45a6-b8af-0bea2bdc1c5c}}
\end{block}

\end{frame}

\begin{frame}{Further work}
\begin{itemize}
\pause \item Replication layer
\pause \item Lazy loading
\pause \item Garbage collection
\pause \item Books, movies, software
\end{itemize}
\end{frame}

\end{document}
