Proposal to allow C++ to be used in gRPC Core

460 views
Skip to first unread message

Craig Tiller

unread,
Apr 1, 2017, 10:34:06 AM4/1/17
to grp...@googlegroups.com
I've created a proposal to allow C++ to be used in gRPC Core here: https://github.com/grpc/proposal/pull/21.

I'm especially interested in hearing from folks in environments where this won't work well.

Craig Tiller

unread,
Apr 1, 2017, 10:39:49 AM4/1/17
to grp...@googlegroups.com

Jan Tattermusch

unread,
Apr 3, 2017, 5:18:45 AM4/3/17
to grpc.io
I remember we went through quite some trouble when trying to build C core so that it is compatible with wide range of libc versions. I expect things to become even worse when libc++ comes into play. My guesstimate is that introducing C++ into C core would cost 2 weeks of work & testing per wrapped language to make sure everything works the way it should (especially around the distribution packages & platform compatibility etc.)
I'm not 100% sure if we could make things work for all languages without harming usability (but I can be convinced - it would be worth to experiment with one wrapped lang. before we decide to go ahead).

Craig Tiller

unread,
Apr 3, 2017, 8:03:24 AM4/3/17
to Jan Tattermusch, grpc.io

Reread the proposal: one of the key requirements here is no libc++ dependency. We'll be using the C++ language, but in a way that avoids all the runtime baggage.

I expect some work for wrapped language folks here, and the implementation plan is careful to ensure we can roll back quickly if this fails (but I don't believe it will).

The advantage for some short term extra effort is a more maintainable and approachable core in perpetuity, and that's a huge advantage long term.

One implementation trick we used on Windows for Python and Ruby was to have two build environments: one for the extension (using whatever the platform required), and another for gRPC, using something more modern. We've got codegen smarts ready to go to dynamically load the c core bits from a DLL without even a link time dependency. I'm certain if we hit painful cases in other wrapped languages we can extend such an approach within days.


--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+u...@googlegroups.com.
To post to this group, send email to grp...@googlegroups.com.
Visit this group at https://groups.google.com/group/grpc-io.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/2e080e70-29b0-4c60-9379-3459ffd3fa4f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jan Tattermusch

unread,
Apr 3, 2017, 11:45:50 AM4/3/17
to Craig Tiller, grpc.io
On Mon, Apr 3, 2017 at 2:03 PM, Craig Tiller <cti...@google.com> wrote:

Reread the proposal: one of the key requirements here is no libc++ dependency. We'll be using the C++ language, but in a way that avoids all the runtime baggage.

I must have missed that, sorry. Without libc++ it sounds more reasonable. 
 

I expect some work for wrapped language folks here, and the implementation plan is careful to ensure we can roll back quickly if this fails (but I don't believe it will)

The advantage for some short term extra effort is a more maintainable and approachable core in perpetuity, and that's a huge advantage long term.

Unless it's more than 1-3 days worth of work for each wrapped lang, it looks like a good investment. 

One implementation trick we used on Windows for Python and Ruby was to have two build environments: one for the extension (using whatever the platform required), and another for gRPC, using something more modern. We've got codegen smarts ready to go to dynamically load the c core bits from a DLL without even a link time dependency. I'm certain if we hit painful cases in other wrapped languages we can extend such an approach within days.

I really hope we won't need to resort to that, but yeah, let's keep it in mind.


On Mon, Apr 3, 2017, 2:18 AM 'Jan Tattermusch' via grpc.io <grp...@googlegroups.com> wrote:
I remember we went through quite some trouble when trying to build C core so that it is compatible with wide range of libc versions. I expect things to become even worse when libc++ comes into play. My guesstimate is that introducing C++ into C core would cost 2 weeks of work & testing per wrapped language to make sure everything works the way it should (especially around the distribution packages & platform compatibility etc.)
I'm not 100% sure if we could make things work for all languages without harming usability (but I can be convinced - it would be worth to experiment with one wrapped lang. before we decide to go ahead).


On Saturday, April 1, 2017 at 4:39:49 PM UTC+2, Craig Tiller wrote:

On Sat, Apr 1, 2017 at 7:33 AM Craig Tiller <cti...@google.com> wrote:
I've created a proposal to allow C++ to be used in gRPC Core here: https://github.com/grpc/proposal/pull/21.

I'm especially interested in hearing from folks in environments where this won't work well.

--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+unsubscribe@googlegroups.com.

Carl Mastrangelo

unread,
Apr 3, 2017, 8:51:02 PM4/3/17
to grpc.io
Are C++ libraries substantially larger than there C counter parts?  Binary size is a serious consideration for Java, perhaps it is for wrapped languages too?

Jan Tattermusch

unread,
Apr 4, 2017, 3:43:25 AM4/4/17
to Carl Mastrangelo, grpc.io
On Tue, Apr 4, 2017 at 2:51 AM, 'Carl Mastrangelo' via grpc.io <grp...@googlegroups.com> wrote:
Are C++ libraries substantially larger than there C counter parts?  Binary size is a serious consideration for Java, perhaps it is for wrapped languages too?

In some wrapped languages, the distribution package contains the binary precompiled for 6 different targets (Linux,Win,Mac x x64,x86; possibly more in the future) so if there's a significant increase in size, it might be inconvenient at least.


On Saturday, April 1, 2017 at 7:34:06 AM UTC-7, Craig Tiller wrote:
I've created a proposal to allow C++ to be used in gRPC Core here: https://github.com/grpc/proposal/pull/21.

I'm especially interested in hearing from folks in environments where this won't work well.

--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+unsubscribe@googlegroups.com.
To post to this group, send email to grp...@googlegroups.com.
Visit this group at https://groups.google.com/group/grpc-io.

Craig Tiller

unread,
Apr 4, 2017, 10:09:20 AM4/4/17
to Jan Tattermusch, Carl Mastrangelo, grpc.io

There's no apriori reason why this should increase binary size: C code compiled as C++ should end up approximately the same size, and we're not introducing new dependencies.

It's probably worth introducing something like a Bloaty McBloatface diff much as we do a benchmark diff, but I'd hold that's an orthogonal issue.


On Tue, Apr 4, 2017, 12:43 AM 'Jan Tattermusch' via grpc.io <grp...@googlegroups.com> wrote:
On Tue, Apr 4, 2017 at 2:51 AM, 'Carl Mastrangelo' via grpc.io <grp...@googlegroups.com> wrote:
Are C++ libraries substantially larger than there C counter parts?  Binary size is a serious consideration for Java, perhaps it is for wrapped languages too?

In some wrapped languages, the distribution package contains the binary precompiled for 6 different targets (Linux,Win,Mac x x64,x86; possibly more in the future) so if there's a significant increase in size, it might be inconvenient at least.


On Saturday, April 1, 2017 at 7:34:06 AM UTC-7, Craig Tiller wrote:
I've created a proposal to allow C++ to be used in gRPC Core here: https://github.com/grpc/proposal/pull/21.

I'm especially interested in hearing from folks in environments where this won't work well.

--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+u...@googlegroups.com.

To post to this group, send email to grp...@googlegroups.com.
Visit this group at https://groups.google.com/group/grpc-io.

--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+u...@googlegroups.com.

To post to this group, send email to grp...@googlegroups.com.
Visit this group at https://groups.google.com/group/grpc-io.

Nicolas Noble

unread,
Apr 4, 2017, 6:16:08 PM4/4/17
to Carl Mastrangelo, grpc.io
Just like with basically everything else, I'd expect that only when exaggerating with the compiler, with excessive templating or code generation for instance. C++ in itself doesn't generate more code than C for the same piece of code. It's what you do with the code that does.

--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+unsubscribe@googlegroups.com.

To post to this group, send email to grp...@googlegroups.com.
Visit this group at https://groups.google.com/group/grpc-io.

Craig Tiller

unread,
Apr 4, 2017, 9:05:47 PM4/4/17
to Nicolas Noble, Carl Mastrangelo, grpc.io
Forwarding a note from the Juniper grpc-c folks:

As long as the public interfaces for grpc_ and gpr_ libs do not change, this library is not effected. Applications using this library link with libgrpc and libgpr. However, one of the reasons for applications to use libgrpc-c instead of libgrpc++ and generated C++ code is compiler support for C++11 in their environment. If gRPC core requires a compiler with C++11 support, they will be stuck with older gRPC release till they migrate to a latest compiler (which they should eventually). But this project will not be effected by this change. Thanks for reaching out.


On Tue, Apr 4, 2017, 3:16 PM Nicolas Noble <pixel...@gmail.com> wrote:
Just like with basically everything else, I'd expect that only when exaggerating with the compiler, with excessive templating or code generation for instance. C++ in itself doesn't generate more code than C for the same piece of code. It's what you do with the code that does.
On Mon, Apr 3, 2017 at 5:51 PM, 'Carl Mastrangelo' via grpc.io <grp...@googlegroups.com> wrote:
Are C++ libraries substantially larger than there C counter parts?  Binary size is a serious consideration for Java, perhaps it is for wrapped languages too?

On Saturday, April 1, 2017 at 7:34:06 AM UTC-7, Craig Tiller wrote:
I've created a proposal to allow C++ to be used in gRPC Core here: https://github.com/grpc/proposal/pull/21.

I'm especially interested in hearing from folks in environments where this won't work well.

--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+u...@googlegroups.com.

To post to this group, send email to grp...@googlegroups.com.
Visit this group at https://groups.google.com/group/grpc-io.

--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+u...@googlegroups.com.

To post to this group, send email to grp...@googlegroups.com.
Visit this group at https://groups.google.com/group/grpc-io.

Craig Tiller

unread,
Apr 13, 2017, 1:28:11 PM4/13/17
to Nicolas Noble, Carl Mastrangelo, grpc.io
Update: we've got an experiment living in https://github.com/grpc/grpc/pull/10427, but are seeing some significant problems mixing C & C++ in the same .so with our current build system on Mac.
Reply all
Reply to author
Forward
0 new messages