[Issue 13159] New: std.socket.getAddress allocates once per DNS lookup hit
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Sat Jul 19 05:26:15 PDT 2014
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 at puremagic.com
Reporter: zorael at 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.)
--
More information about the Digitalmars-d-bugs
mailing list