Both Pipeline and DocumentSource copy {{intrusive_ptr}}s unnecessarily. Instead, they can be moved to avoid a branch and the modification of the atomic counter variable.
Additionally, a few methods in Pipeline (usedDisk, canParameterize) can be made const.
Finally, the files containing Pipeline and DocumentSource include a lot of headers unnecessarily. We should remove the unnecessary headers to reduce dependencies.