Skip Ford ported Tim Robbins’ FreeBSD port of Niels Provos’ NetBSD file descriptor allocation code. Normally I don’t post about code until it gets committed, but he posted some numbers on how well it improves things, as benchmarked by Niels Provos’ test program that opens/closes files repeatedly. The numbers seem to indicate a 50% speedup:
| File Descriptors | Unpatched | Patched |
| 1 | 0.765650 | 0.781279 |
| 2001 | 1.148484 | 0.789092 |
| 4001 | 1.546935 | 0.765657 |
| 6001 | 2.062582 | 0.781276 |
| 8001 | 2.515725 | 0.796906 |
| 10001 | 3.086061 | 0.796904 |
| 12001 | 3.632955 | 0.765654 |
| 14001 | 4.086098 | 0.757841 |
| 16001 | 4.515805 | 0.820343 |
| 18001 | 4.976759 | 0.812530 |
| 20001 | 5.429916 | 0.796905 |
| 22001 | 5.898652 | 0.773467 |
| 24001 | 6.336188 | 0.773455 |
| 26001 | 6.750268 | 0.804718 |
| 28001 | 7.179972 | 0.789091 |
| 30001 | 7.633110 | 0.781281 |
| 32001 | 8.070632 | 0.789091 |
| 34001 | 8.523771 | 0.796906 |
| 36001 | 8.953479 | 0.789092 |
| 38001 | 9.375370 | 0.765656 |
| 40001 | 10.117587 | 0.789090 |
| 42001 | 10.758238 | 0.789091 |
| 44001 | 11.367636 | 0.804718 |
| 46001 | 11.820781 | 0.812531 |
| 48001 | 12.453618 | 0.812530 |

Seems more like the code first was O(n) and now its O(1).