Merge "Performance optimizations for applyBatch" into mainline-prod