mongodb/node-mongodb-native — pull request #804 by Swatinem (2012-12-14 11:59:11+00:00)
Title: Cursor.each should work in batches

Currently, Cursor.each uses a really inefficient process.nextTick -> nextObject() -> recurse to self
loop.

This patch avoids this behavior and rather loops over a batch directly, providing a nice speedup up to 2x depending on workload.

The benchmarks I have done are available at Swatinem/mongobench. I can observe the following speedups:
![line](https://f.cloud.github.com/assets/580492/13140/697bf214-45e5-11e2-9b3c-f7dc95453bf8.png)
![jitter](https://f.cloud.github.com/assets/580492/13141/6e0355de-45e5-11e2-948a-036a9ace1976.png)

The patched version however uses more memory:
![heap-total](https://f.cloud.github.com/assets/580492/13147/961e740e-45e5-11e2-8f33-c9f5115c78fc.png)

I might need some help fixing that.