When making a new block template only perform GetMemPoolAncestors()
as frequently as is actually needed. It's a relatively expensive operation, although only taking a couple of microseconds, when multiplied by 500,000 or 1,000,000 it starts to have a negative effect on template creation. Especially given that most transactions don't have parents and therefore this function call rarely needs to get executed.