digitalmars.D.bugs - [Issue 13159] New: std.socket.getAddress allocates once per DNS
- via Digitalmars-d-bugs (24/30) Jul 19 2014 https://issues.dlang.org/show_bug.cgi?id=13159
https://issues.dlang.org/show_bug.cgi?id=13159
Issue ID: 13159
Summary: std.socket.getAddress allocates once per DNS lookup
hit
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: enhancement
Priority: P1
Component: Phobos
Assignee: nobody puremagic.com
Reporter: zorael gmail.com
[Arch x86_64, dmd/phobos/druntime from git 140719]
std.socket.getAddress is very allocation-happy. A DNS lookup often/(always?)
gives more than one resulting IP, and getAddress naïvely concatenates each into
an Address[] array in a foreach loop. As a concrete example,
getAddress("irc.freenode.net", cast(ushort)6667) returned 51 hits.
In Address[] getAddress(in char[], in char[]) near line 1116:
// use getAddressInfo
Address[] results;
auto infos = getAddressInfo(hostname, service);
foreach (ref info; infos)
results ~= info.address;
return results;
Unless this is a valid use-case for ScopeBuffer, could we at least tack a
results.reserve(64) in there?
(I think AddressInfo.sizeof is 40 bytes.)
--
Jul 19 2014








via Digitalmars-d-bugs <digitalmars-d-bugs puremagic.com>