Files
papers/lux-firebase-exit/sections/06-performance-comparison.tex
zeekay abf99d05fc papers: reorganize into per-paper dirs, add Antje Worring as co-author
Restructured from flat .tex/.pdf files into per-paper subdirectories.
Added Antje Worring as co-author on all papers.
Synced PDFs to pdfs/ for download site.
2026-04-18 21:50:07 -07:00

81 lines
2.9 KiB
TeX

\section{Performance Comparison}
\label{sec:performance}
The primary performance advantage of the capsule architecture is the
elimination of network round-trips for reads. We benchmark local SQLite
against Firestore for common operations.
\subsection{Read Latency}
\begin{table}[H]
\centering
\caption{Read latency comparison: Firestore vs.\ local encrypted SQLite.}
\label{tab:read-latency}
\begin{tabular}{lrrr}
\toprule
\textbf{Operation} & \textbf{Firestore (ms)} & \textbf{SQLite (ms)} & \textbf{Speedup} \\
\midrule
Single document read & 50--200 & 0.1--0.5 & $100\times$--$400\times$ \\
Collection query (100 docs) & 100--500 & 1--5 & $100\times$ \\
Full-text search (10K docs) & 200--1000 & 5--20 & $40\times$--$50\times$ \\
Aggregation (COUNT, SUM) & 100--300 & 0.5--2 & $150\times$--$200\times$ \\
Join (2 collections) & N/A (not supported) & 2--10 & $\infty$ \\
\bottomrule
\end{tabular}
\end{table}
Firestore latency includes DNS resolution, TLS handshake (for cold
connections), HTTP/2 framing, Firestore query execution, and response
serialization. SQLite latency is a local disk read (or memory read if
the page is cached) plus decryption. The SQLCipher encryption overhead
is approximately 5--10\% relative to unencrypted SQLite.
\subsection{Write Latency}
\begin{table}[H]
\centering
\caption{Write latency comparison: Firestore vs.\ local SQLite + CRDT sync.}
\label{tab:write-latency}
\begin{tabular}{lrr}
\toprule
\textbf{Operation} & \textbf{Firestore (ms)} & \textbf{SQLite + CRDT (ms)} \\
\midrule
Single document write & 100--500 & 0.5--2 (local) + async sync \\
Batch write (100 docs) & 500--2000 & 5--20 (local) + async sync \\
Transaction (read-write) & 200--1000 & 1--5 (local) \\
\bottomrule
\end{tabular}
\end{table}
Writes in the capsule model are local-first: the write completes
immediately against the local SQLite database, and synchronization
happens asynchronously in the background. The user experiences write
latency of under 2~ms for single documents, compared to 100--500~ms
for Firestore (which requires a network round-trip to confirm the write).
\subsection{Offline Behavior}
\begin{table}[H]
\centering
\caption{Offline capability comparison.}
\label{tab:offline}
\begin{tabular}{lcc}
\toprule
\textbf{Capability} & \textbf{Firestore} & \textbf{Capsule} \\
\midrule
Read cached data offline & Yes (limited cache) & Yes (full database) \\
Write offline & Yes (queued, limited) & Yes (full, unlimited) \\
Conflict resolution & Last-write-wins & CRDT merge (semantic) \\
Offline duration limit & Cache eviction & None \\
Full query support offline & Partial & Full SQL \\
\bottomrule
\end{tabular}
\end{table}
Firestore's offline mode caches recently accessed documents and queues
writes for later synchronization. The cache has size limits (default 40~MB
on web, 100~MB on mobile), and queries over uncached data fail. The
capsule model has no such limitations: the entire database is local,
all queries work, and there is no cache eviction.