elasticsearch/elasticsearch — pull request #5589 by hhoffstaette (2014-03-28 08:04:16+00:00)
Title: Restore streamInput() performance over PagedBytesReference.

The initial implementation of bulk-reading a streamInput() over PagedBytesReference was slow (byte-by-byte reading when bulk copying).

Times in µs for bulk-reading a stream over plain vs. paged:

| MB | plain µs | paged µs | Ratio |
|-----|----------|----------|-------|
| 1 | 72 | 2048 | 28.6 |
| 2 | 140 | 4127 | 29.4 |
| 3 | 218 | 6208 | 28.4 |
| 4 | 430 | 8396 | 19.5 |
| 5 | 700 | 10525 | 15.0 |
| 10 | 1739 | 21055 | 12.1 |
| 20 | 3481 | 42063 | 12.1 |
| 50 | 8701 | 105337 | 12.1 |
| 100 | 17409 | 210848 | 12.1 |

This changeset restores performance:

| MB | plain µs | paged µs | Ratio |
|-----|----------|----------|-------|
| 1 | 65 | 68 | 1.05 |
| 2 | 134 | 141 | 1.04 |
| 3 | 198 | 235 | 1.18 |
| 4 | 456 | 418 | 0.91 |
| 5 | 750 | 761 | 1.01 |
| 10 | 1736 | 1743 | 1.00 |
| 20 | 3514 | 3497 | 0.99 |
| 50 | 8706 | 8700 | 0.99 |
| 100 | 17608 | 17731 | 1.00 |

The performance jitters slightly due to the usual Hotspot variances, OS scheduling etc. For all practical purposes the performance is now back to what it was before.