Table of Contents
Fetching ...

Piece of CAKE: Adaptive Execution Engines via Microsecond-Scale Learning

Zijie Zhao, Ryan Marcus

TL;DR

This work tackles kernel selection for low-level database operators by introducing CAKE, a microsecond-scale contextual multi-armed bandit that leverages counterfactual feedback to learn per-morsel kernel choices. CAKE blends online learning with a global convergence plan, culminating in regret-tree compilation that enables near-zero-overhead inference once the policy stabilizes. Empirical results across IMDb, Stack, and DSB datasets show up to a 2x reduction in end-to-end latency compared to static heuristics and strong performance close to an oracle, with modest overhead and remarkable sample efficiency. The approach offers a practical, plug-in path for making DBMSs adaptive to data distributions without requiring manual per-dataset tuning, promising substantial real-world speedups for complex analytical workloads.

Abstract

Low-level database operators often admit multiple physical implementations ("kernels") that are semantically equivalent but have vastly different performance characteristics depending on the input data distribution. Existing database systems typically rely on static heuristics or worst-case optimal defaults to select these kernels, often missing significant performance opportunities. In this work, we propose CAKE (Counterfactual Adaptive Kernel Execution), a system that learns to select the optimal kernel for each data "morsel" using a microsecond-scale contextual multi-armed bandit. CAKE circumvents the high latency of traditional reinforcement learning by exploiting the cheapness of counterfactuals -- selectively running multiple kernels to obtain full feedback -- and compiling policies into low-latency regret trees. Experimentally, we show that CAKE can reduce end-to-end workload latency by up to 2x compared to state-of-the-art static heuristics.

Piece of CAKE: Adaptive Execution Engines via Microsecond-Scale Learning

TL;DR

This work tackles kernel selection for low-level database operators by introducing CAKE, a microsecond-scale contextual multi-armed bandit that leverages counterfactual feedback to learn per-morsel kernel choices. CAKE blends online learning with a global convergence plan, culminating in regret-tree compilation that enables near-zero-overhead inference once the policy stabilizes. Empirical results across IMDb, Stack, and DSB datasets show up to a 2x reduction in end-to-end latency compared to static heuristics and strong performance close to an oracle, with modest overhead and remarkable sample efficiency. The approach offers a practical, plug-in path for making DBMSs adaptive to data distributions without requiring manual per-dataset tuning, promising substantial real-world speedups for complex analytical workloads.

Abstract

Low-level database operators often admit multiple physical implementations ("kernels") that are semantically equivalent but have vastly different performance characteristics depending on the input data distribution. Existing database systems typically rely on static heuristics or worst-case optimal defaults to select these kernels, often missing significant performance opportunities. In this work, we propose CAKE (Counterfactual Adaptive Kernel Execution), a system that learns to select the optimal kernel for each data "morsel" using a microsecond-scale contextual multi-armed bandit. CAKE circumvents the high latency of traditional reinforcement learning by exploiting the cheapness of counterfactuals -- selectively running multiple kernels to obtain full feedback -- and compiling policies into low-latency regret trees. Experimentally, we show that CAKE can reduce end-to-end workload latency by up to 2x compared to state-of-the-art static heuristics.
Paper Structure (17 sections, 1 theorem, 9 equations, 10 figures, 6 tables, 2 algorithms)

This paper contains 17 sections, 1 theorem, 9 equations, 10 figures, 6 tables, 2 algorithms.

Key Result

Theorem 1

Selection Consistency. As the size of observed history $n$ increases, the probability of CAKE selecting the suboptimal kernel for a query morsel $q$ approaches zero linearly assuming variance-bounded noise, and exponentially assuming sub-Gaussian noise.

Figures (10)

  • Figure 1: Latency of our IMDb workload using different kernel selection algorithms. Choosing the right kernels for each morsel can have a large performance impact. See Section \ref{['sec:expr']}.
  • Figure 2: System Diagram
  • Figure 3: Minimizing regret vs maximizing accuracy. Each point is annotated with the penalty of misclassification.
  • Figure 4: Latency comparison across datasets
  • Figure 5: Cumulative Distribution Function (CDF) for query latencies. A gap between the curves indicates strictly better performance (at all quantiles) of the lower curve. ❶ shows the performance gain of our method over the heuristic baseline, achieving performance nearly indistinguishable from the optimal oracle at P80.
  • ...and 5 more figures

Theorems & Definitions (1)

  • Theorem 1