A quick follow-up to #12417 to reorganize the baseBatchStage code into its own file. Avoided to pack into the existing batch stage PR to avoid conflicts with stacked PRs.
nit: It feels a little weird to have BatchQueue defined in the middle of baseBatchStage functions. Might be worth keeping the baseBatchStage stuff together and the two implementations either below or in separate files.
Originally posted by @ajsutton in #12417 (comment)