Comments (16)
Hi, thanks for the link, looks neat :).
Do you think it makes sense to collaborate in some way, should asio-grpc maybe provide a backend for your library? Would that even make sense?
from asio-grpc.
Yes, welcome to integrate our lib into your project.
By the way I saw your performance data, I think the reason c++ grpc-asio slower than go-grpc is that asio is weak in steaming socket mode, compared with Golang. See our tests in https://github.com/alibaba/PhotonLibOS#21-tcp , however, much better in ping-ping mode.
from asio-grpc.
Mmh, this library does not use asio's socket classes whatsoever. All I/O is handled by gRPC itself (epoll event engine).
The go-grpc server used to be much slower until it started uses a very fast Protobuf implementation: https://github.com/planetscale/vtprotobuf. So I suspect that is the performance bottleneck in the asio-grpc server.
I had a brief look at your library and I think it should be rather simple to bridge from your mutex+condition_variable to asio or libunifex and thereby into asio-grpc.
from asio-grpc.
Is there any way to replace gRPC's epoll engine and use customized socket?
from asio-grpc.
And our mutex and condition variable is based on our own event engine
from asio-grpc.
Not yet, but they are working on it: https://github.com/grpc/grpc/tree/master/include/grpc/event_engine
from asio-grpc.
So you will create two threads, one for grpc event loop, and the other for your own ?
And with across-thread communication
from asio-grpc.
gRPC exposes the event loop through CompletionQueue which I wrap and run on one thread. I suspect that a naïve implementation against your library would create another thread for your library. Maybe there is another way, does your library have the concept of an event loop and allows polling it?
from asio-grpc.
I think that is a problem. Some old codes have their own event loop, and when they decide to use gRPC, they find it unlikely to integrate into gRPC's own loop.
Our library has the polling mechanism, and all the mutex and cv are running within event loop. The mutex and cv can work across mutil-thread, they are equivalant to std::mutex and std::cv, the only difference is that they are designed for coroutines.
from asio-grpc.
epoll engine can be cascading. I suspect you can use our event engine and then poll the one of gRPC, if it has exposed its fd.
from asio-grpc.
Cross-thread communication is also feasible. We have a semaphore (based on eventfd), that can do wait / notify.
from asio-grpc.
Yep gRPC having its own event loop was also the challenge with asio-grpc. With the gRPC event_engine it should be possible to pluck something like asio::io_context
in natively, which makes things a little cleaner.
Your code is the best we can do at the moment I believe and it doesn't even require asio-grpc :).
from asio-grpc.
But cross-thread communication is not effective in terms of performance...
from asio-grpc.
I am afraid that is the best we can do with gRPC's current API.
Once the event_engine can be customized it will be possible to cq->Next() in the I/O thread without blocking it.
from asio-grpc.
I started playing with the EventEngine a bit https://github.com/Tradias/asio-grpc/blob/event-engine/test/utils/utils/grpc_context_test.cpp but it is still too experimental. gRPC only uses the engine for some experimental features like load balancing and service discovery which makes it very difficult to test the EventEngine. I have put my efforts on hold for now.
Anyways, I hope you understand why asio-grpc provides an entire asio::execution_context
-compatible wrapper for gRPC's CompletionQueue. Simple services/clients can then be written without cross-thread communication and everything else can reach out to e.g. an asio::io_context
and use asio's completion token system to bounce between the two contexts/threads.
from asio-grpc.
Hi, I will close the issue until gRPC has made significant progress on their EventEngine. Feel free to open another issue if you have any more questions or suggestions for asio-grpc.
from asio-grpc.
Related Issues (20)
- [Question] : How to detect client disconnection HOT 18
- Questions about CPU usage and event multiplexing HOT 3
- GRPC_CALL_ERROR_TOO_MANY_OPERATIONS Error on Concurrent Write Operations HOT 2
- Lifetime issue in the docs HOT 2
- Example with small changes crashes HOT 6
- Why I get const correctness problems HOT 16
- Generic server example without manual buffer serializaiton? HOT 4
- Using asynchronous gRPC server and client on same context HOT 9
- Asio-gRPC seems to have TSAN warnings HOT 8
- How to detect client closed connection HOT 6
- Can I call ServerBuilder::BuildAndStart() after GrpcContext::run() HOT 2
- Questions on how to switch from an GrpcContext to io_context and back HOT 6
- How to shutdown grpc clients HOT 1
- Clarification Needed on Thread Context Switch in writer() Function (example streaming-server.cpp) HOT 8
- assertion failed: !started_ HOT 2
- Can I use asio-grpc inside an existing boost::asio application? HOT 7
- The agrpc::GrpcContext hangs forever HOT 13
- an upgrade from 2.5.1 to 2.9.1 leads to build errors HOT 6
- build fails with latest boost 1.84 HOT 4
- [Question]: Slowly receiveing client in long-lived streaming HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from asio-grpc.