Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix IPv6 requests in the HTTP client #2082

Merged
merged 3 commits into from
Feb 24, 2018
Merged

Conversation

s-ludwig
Copy link
Member

No description provided.

@s-ludwig s-ludwig force-pushed the issue2080_http_client_ipv6 branch 2 times, most recently from a7d7995 to 28aabf5 Compare February 23, 2018 12:49
@@ -0,0 +1,32 @@
/++ dub.sdl:
dependency "vibe-d" version="~>0.8.3-alpha.4"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be path too? (we probably should allow single files in the test suite too)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True and true!

} catch (Exception e) assert(false, e.msg);
});
runApplication();
} else logWarn("Skipping HTTP+IPv6 test due to Travis not supporting IPv6 loopback");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably gets forgotten easily. Have you considering removing the test in the travis.sh script?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


// Provide port number when it is not the default one (RFC2616 section 14.23)
// IPv6 addresses need to be put into brackets
auto hoststr = url.host.canFind(':') ? "["~url.host~"]" : url.host;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you care about performance, choose(url.host.canFind(':'), url.host, chain("[", url.host, "]")) does this without allocation.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the result is needed as a string anyway, so until there is range support for writing headers, it wouldn't really save anything.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

format uses an appender internally and thus is probably a tiny bit faster, but yeah I agree that it won't be noticeable and the the real gain will come from not allocating at all.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIR, multiple ~ expressions are automatically joined efficiently by counting the total length first and allocating only a single buffer. I never verified this, though.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIR, multiple ~ expressions are automatically joined efficiently by counting the total length first and allocating only a single buffer.

Yes (https://github.com/dlang/druntime/blob/master/src/rt/lifetime.d#L2217), but it's still an allocation.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But Appender has to allocate, too. Or do you mean something else?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but my point was it has to do so in any case at the moment and one big allocation might be a tiny bit faster.
Anyhow, I doubt that it will matter and I wouldn't be too shocked if at the moment the implementation of format would even be slower due to the non-zero cost abstraction of ranges , simply not calling reserve on the appender, the appender itself being slow etc. . Unfortunately, Phobos does a really poor job performance-wise at the moment :/

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get it :) So _d_arraycatnTX does a single big allocation, too (actually an allocation with the exact length, while Appender probably over-allocates?). Why would it be slower than Appender?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, but anyway, it's not really important right now. Just the new vibe-http should get a low level API that avoids these kinds of allocations.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get it :) So _d_arraycatnTX does a single big allocation, too (actually an allocation with the exact length, while Appender probably over-allocates?). Why would it be slower than Appender?

Ah I think we were talking about different things.
I was trying to say that the combination of e.g.

auto s = a ~ "foo" ~ b;
return format("%s%s", ".", s); // <- allocates again with an appender

in a perfect world is slower than

auto s = chain(a, "foo", b);
return format("%s%s", ".", s);

Yeah, but anyway, it's not really important right now.

Yes!

@wilzbach wilzbach merged commit 570797f into master Feb 24, 2018
@wilzbach wilzbach deleted the issue2080_http_client_ipv6 branch February 24, 2018 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants