512KB are clearly to small. We use 2mb on all our systems (including production, were we have about 100 connection threads configured). However, i don't see, were the document size has an influence on the stack size diff. As long there is no recursion, the document size should not require a larger stack. Are you using already the version with ::util::diff? If you see a recursion, where does it happen?