Continuous batching from first principles