-
Notifications
You must be signed in to change notification settings - Fork 284
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
hide SSL implementation headers behind interfaces #757
Conversation
MartinNowak
commented
Jul 30, 2014
- turn SSLStream and SSLContext into interfaces
- move OpenSSL based implementation to vibe.stream.openssl
- turn SSLStream and SSLContext into interfaces - move OpenSSL based implementation to vibe.stream.openssl
Please review carefully, I just did this very mechanically. This time I do have numbers. The raw compile time as measured here went down from 0.8s to 0.4s. Number of imported files was reduced from 202 to 152, LOC went from 222.5K to 192.7K and code size dropped from 8M to 6.8M. |
So, this means there could be a use to a pragma-based compile-time profiler? :-P Best I could find is this: http://forum.dlang.org/thread/[email protected] |
Updated graph (http://jsfiddle.net/DJqjD/), the next victim will be dub :). |
From the old and the new perf histogram one can see, that the compiler has to do a huge amount of symbol lookups for openssl. |
/// The kind of SSL context (client/server) | ||
@property SSLContextKind kind() const { return m_kind; } | ||
@property SSLContextKind kind(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The const
seems to be accidentally dropped here.
Apart from the missing Looks like an impressive compile time reduction for one small component. But judging be the monster that the OpenSSL API is, its actually not surprising ;) BTW, Vladimir also made this useful little tool that would split up the build time into its components (that he also demonstrated on DConf): DBuildStat - that gave some interesting insights in an earlier attempt to reduce compile times. |
PS: I wanted to integrate some simple profiling into DUB that could be enabled with a command line switch, but didn't get around to it yet. That would probably help a lot to quickly identify where the time is wasted. |
Updated.
So we could move the |
To make another case for |
I think so, too. They are used relatively rarely and are just two lines, so it doesn't relly buy much in terms of either performance or saving code.
Event divers are separate, they have always been full interfaces. But it's definitely good to have that possibility opened up for SSL streams, too. Now the only thing missing would be to have a registration facility for alternative implementations, so that |
Hide SSL implementation headers behind interfaces.
Would be a good selling point to have GNUTLS and PolarSSL plugins. version (VibeCustomSSL) {
interface SSLFactory {
SSLContext createSSLContext(SSLContextKind kind, SSLVersion ver = SSLVersion.any);
SSLStream createSSLStream(Stream underlying, SSLContext ctx, SSLStreamState state, string peer_name = null, NetworkAddress peer_address = NetworkAddress.init);
}
void setSSLFactory(SSLFactory factory) { s_sslFactory = factory; }
}
SSLStream createSSLStream(Stream underlying, SSLContext ctx, SSLStreamState state, string peer_name = null, NetworkAddress peer_address = NetworkAddress.init)
{
version (VibeNoSSL) assert(false, "No SSL support compiled in (VibeNoSSL)");
else version (OpenSSL) {
import vibe.stream.openssl;
return new OpenSSLStream(DEPRECATION_HACK.init, underlying, cast(OpenSSLContext)ctx,
state, peer_name, peer_address);
} else version (VibeCustomSSL) {
enforce(s_sslFactory, "No SSL Factory provided.");
return s_sslFactory.createSSLStream(underlying, ctx, state, peer_name, peer_address);
}
} Or plain function pointers. version (VibeCustomSSL)
void setCreateSSLStream(typeof(&createSSLStream) func) { s_createSSLStream = func; }
SSLStream createSSLStream(Stream underlying, SSLContext ctx, SSLStreamState state, string peer_name = null, NetworkAddress peer_address = NetworkAddress.init)
{
// ...
} else version (VibeCustomSSL)
return s_createSSLStream(/*Args*/);
} |
Wait a minute... that
|
The sanest SSL stream would be Botan, I'll be using the algorithm factory for the TLS engine I'm working on but it does have a decent TLS engine already out of the box Also, it has been shown to statically compile with an amalgamation script used in Titanium https://github.com/ellipticbit/titanium It looks like it's a hot subject so I'm going to re-open my work on native events right now see if I can move it into a driver this week. |
What are you working on, epoll, kqueue or something else? |
I'm working on epoll and iocp at first. I put it on hold before finishing and making a pull request because I developed it too fast (10 days) and I wasn't sure if I would change my mind on certain things. https://github.com/etcimon/vibe.d/tree/native-events/source/vibe/core/events |