Message307651
https://github.com/python/cpython/pull/4724
`recvfrom` from multicast socket is painfull slow. In fact, it returns sender address in form:
`('fe80::941f:f6ff:fe04:c560%qwe', 42133, 0, 78)`
which is superfluous, since interface-name part (`%qwe`) is not actually used. Actually, scopeid (`78`) signify interface/scope/zone_id. This tuple can be used for `.sendto()` either with this interface-name-part or without.
The problem is in the performance. For each `recvrfom()`, `getnameinfo()` internally converts interface index to interface name using three syscalls, i.e. `socket(), getsockopt()?, close()` , which slows down receiving (I have not measured result, but see additional syscalls in `strace`).
In order to convert from tuple to string-based full address one may use `getnameinfo()`:
As you can see, initial interface is ignored (but without my patch it is also validated uselessly):
```
In[1]: socket.getnameinfo(('fe80::941f:f6ff:fe04:c560%qwe', 42133, 0, 78), socket.NI_NUMERICHOST)
Out[1]: ('fe80::941f:f6ff:fe04:c560%qwe', '42133')
In[2]: socket.getnameinfo(('fe80::941f:f6ff:fe04:c560', 42133, 0, 78), socket.NI_NUMERICHOST)
Out[2]: ('fe80::941f:f6ff:fe04:c560%qwe', '42133')
``` |
|
Date |
User |
Action |
Args |
2017-12-05 09:54:54 | socketpair | set | recipients:
+ socketpair |
2017-12-05 09:54:54 | socketpair | set | messageid: <1512467694.45.0.213398074469.issue32221@psf.upfronthosting.co.za> |
2017-12-05 09:54:54 | socketpair | link | issue32221 messages |
2017-12-05 09:54:54 | socketpair | create | |
|