The NetBSD and OpenBSD getaddrinfo lock fix is in progress: http://bugs.python.org/issue26406
Meanwhile, I wrote a benchmark to answer your question, Guido. I used all the combinations of getaddrinfo parameters (host, port, family, socket type, protocol) that I used to test my asyncio patch <https://github.com/python/asyncio/commit/39c135ba>, and I timed a hundred thousand calls to BaseEventLoop.getaddrinfo with those parameters. Here's the benchmark script: https://gist.github.com/ajdavis/8f76f09bf15d552acddb I'm quite surprised to find that my Python code is much faster than the raw getaddrinfo calls were before. With asyncio at 39c135b (my patch), a hundred thousand calls to BaseEventLoop.getaddrinfo takes: host port family type proto secs 1.2.3.4 1 2 1 6 3.5 1.2.3.4 1 0 1 6 3.5 1.2.3.4 1 0 2 17 3.5 1.2.3.4 1 0 1 0 3.5 1.2.3.4 1 0 2 0 3.9 1.2.3.4 1 0 0 0 28.1 ::3 1 30 1 6 3.7 ::3 1 0 1 6 3.9 ::3%lo0 1 30 1 6 3.7 The script clears the info cache each iteration. The slow 28-second line is with socket type "0". It's slow because it falls back to normal getaddrinfo. Compare these numbers to asyncio at 74f2d8c (before my patch): host port family type proto secs 1.2.3.4 1 2 1 6 26.6 1.2.3.4 1 0 1 6 27.2 1.2.3.4 1 0 2 17 26.7 1.2.3.4 1 0 1 0 27.2 1.2.3.4 1 0 2 0 26.4 1.2.3.4 1 0 0 0 27.8 ::3 1 30 1 6 26.1 ::3 1 0 1 6 27.4 ::3%lo0 1 30 1 6 31.5 This is on Mac OS X 10.10.5 with a recent build of Python master (at Mercurial revision 100282), which does *not* lock around getaddrinfo on my Mac now. *Conclusion:* it looks like the patch was worthwhile regardless of the getaddrinfo lock. On Monday, February 15, 2016 at 11:31:23 AM UTC-5, Guido van Rossum wrote: > > On Sun, Feb 14, 2016 at 10:47 PM, A. Jesse Jiryu Davis > <[email protected] <javascript:>> wrote: > > Ned merged my patches, so Python 3.6 and the next releases of Python 2.7 > and > > 3.5 won't lock around getaddrinfo on Mac 10.5+. > > Great! > > > getaddrinfo is also thread-safe on recent NetBSD 4 and OpenBSD 5.4+. I > plan > > to submit similar version checks for them. (FreeBSD already has the > proper > > version check.) > > That's also great to hear. Determination! > > > In other words the lock is about to be removed on all modern platforms. > > Should we revert this asyncio change? It's a complex solution to a > problem > > that's going away. > > Humm... Do you for sure that getaddrinfo() can parse numeric IP > addresses (of all flavors) faster than the Python code you wrote, > barring the lock? If that's so I agree. > > -- > --Guido van Rossum (python.org/~guido) >
