Comments (18)
What is the max size of your req/resp? And the RTT between client/server?
from srpc.
once every 1 millisecond. only one client
from srpc.
RTT about 2ms
from srpc.
Could you also try task mode and compare the response time with sync mode?
from srpc.
how to set task mode?
from srpc.
You can refer to the usage here: https://github.com/sogou/srpc/blob/master/tutorial/tutorial-09-client_task.cc#L32
void callback(::XrPackage::PoseResponse *resp, RPCSyncContext *ctx)
{
// process response
}
int main()
{
::XrPackage::PoseRequest req;
// ... set req
auto *rpc_task = client.create_XXX_task(callback);
rpc_task->serialize_input(&req);
rpc_task->start();
// please make sure your main thread will not exit here
}
Please check your generated file xxxx.srpc.h
to find the definition of create_XXX_task()
.
from srpc.
use task mode to get pose, it also spend 100ms or more to get data from server (the client and server are both android device)
from srpc.
Hi, I think there are some other ways to debug:
-
Usage. Is your code simple enough to only send this task in parallel (and not doing other things, to avoid other influences). And then we can check if the latency is stable to 10ms+ or still unstable from 10ms+ to 100ms.
-
Data size. As we know, protobuf serialization is very slow for large data or data with map(partly because map has discontinuous memory). So we can check if the slow latency is caused by large data.
-
Latency calculation. You may use the internal
trace module
to monitor the latency. It begins counting when the task is really start and ends after receive and deserialization. So I think it is more accurate. You may check if this time is also nearly 100ms.
Check the usage of trace module
as follow:
#include "srpc/rpc_trace_filter.h"
int main()
{
...
RPCTraceDefault span_log; // this plugin will print the trace info on the screen
client.add_filter(&span_log);
...
}
from srpc.
thanks ,I will try
from srpc.
only send pose,the max time value is 16ms,but not stable. where can I set dscp (socket) in workflow? is it in nonblock_connect method in Communicator?
int dscp = 0x2E;
if (setsockopt(mSockfd, IPPROTO_IP, IP_TOS, &dscp, sizeof(dscp)) != 0)
from srpc.
- What do you mean ' only send pose' ? You mean sending doesn't take much time, so the problem is with connecting or receiving?
- Inside Communicator, it is nonblock_connect.
- You cannot setsockopt.
from srpc.
1.only send pose that mean simple enough to only send this task in parallel,here are also data points with durations over 100 milliseconds, but they are relatively few in comparison.
2.I want to set priority in socket,so it can send data fast.is it support(dscp)?
3.when I use UDP,it seems something wrong,so is it support UDP in old version workflow(last year)
4.use tcpdump,and found send data and receive data very quickly( under 20ms ),but application receive sometimes cost 100ms
from srpc.
-
It seems simple enough when you only send pose. There are some point you can check:
- What's the data size? (The time for protobuf to deserialize may be long.)
- What is the CPU utilization at that time?
-
About setting the socket priority, you cannot get the fd so you cannot setsockopt(). If your dependencies are source code, maybe you can add the code in Communicator.cc . But as you mentioned you already tcpdump and the network is really quick, I think it is not about the network. Maybe you can also try to run client and server on the same machine to avoid the unstable network and we can see whether the long latency is caused by the framework.
-
You can send UDP as client side in older version Workflow. ( BTW, you can post the ERROR when you use UDP. I would like to solve it.)
from srpc.
thank for your reply,so how can I set UDP,since the constuctor has no type set as followed
struct RPCClientParams
{
RPCTaskParams task_params;
//host + port + is_ssl
std::string host;
unsigned short port;
bool is_ssl;
//or URL
std::string url;
int callee_timeout;
std::string caller;
};
from srpc.
UDP transmission was supported in the lastest release, but only available for Unix system.
Line 39 in 627f69c
When the 'transport_type' field is TT_UDP, the client will use UDP.
from srpc.
Please update to the lastest releases, workflow and SRPC.
from srpc.
目前用自己写的通信库看UDP数据传输还是挺稳定的,所以暂时不用srpc方案了。谢谢!
from srpc.
如果可以,也麻烦帮我们试一下如果只用workflow的UDP,是否也有问题。
#include <stdio.h>
#include <string>
#include <iostream>
#include "workflow/WFGlobal.h"
#include "workflow/WFFacilities.h"
#include "workflow/TLVMessage.h"
#include "workflow/WFTaskFactory.h"
#include "workflow/WFServer.h"
using namespace protocol;
using WFTLVServer = WFServer<TLVRequest, TLVResponse>;
using WFTLVTask = WFNetworkTask<TLVRequest, TLVResponse>;
using tlv_callback_t = std::function<void (WFTLVTask *)>;
WFTLVTask *create_tlv_task(const char *host, unsigned short port, tlv_callback_t callback)
{
auto *task = WFNetworkTaskFactory<TLVRequest, TLVResponse>::create_client_task(
TT_UDP, host, port, 0, std::move(callback)); // 创建UDP传输的client任务
task->set_keep_alive(60 * 1000);
return task;
}
int main()
{
struct WFServerParams params = SERVER_PARAMS_DEFAULT;
params.transport_type = TT_UDP; // 这里把server的传输协议改为UDP
WFTLVServer server(¶ms, [](WFTLVTask *task) {
*task->get_resp() = std::move(*task->get_req());
});
if (server.start(8888) != 0) {
perror("server.start");
exit(1);
}
auto&& create = [](WFRepeaterTask *)->SubTask * {
std::string string;
printf("Input string (Ctrl-D to exit): ");
std::cin >> string;
if (string.empty())
return NULL;
auto *task = create_tlv_task("127.0.0.1", 8888, [](WFTLVTask *task) {
if (task->get_state() == WFT_STATE_SUCCESS)
printf("Server Response: %s\n", task->get_resp()->get_value()->c_str());
else {
const char *str = WFGlobal::get_error_string(task->get_state(), task->get_error());
fprintf(stderr, "Error: %s\n", str);
}
});
task->get_req()->set_value(std::move(string));
return task;
};
WFFacilities::WaitGroup wait_group(1);
WFRepeaterTask *repeater = WFTaskFactory::create_repeater_task(std::move(create), nullptr);
Workflow::start_series_work(repeater, [&wait_group](const SeriesWork *) {
wait_group.done();
});
wait_group.wait();
server.stop();
return 0;
}
from srpc.
Related Issues (20)
- Srpc无法正确生成官方hbase.thrift的srpc客户端 HOT 24
- Support in API testing tool linuxsuren/api-testing HOT 7
- srpc和workflow配合使用问题 HOT 19
- 在SRPCHttpServer上启用trace上报opentelemtry功能异常 HOT 6
- 关于 RPCBuffer 中 read_back 问题 HOT 3
- 关于 RPCBuffer::cut 和 BRPC 中的 attachment 使用的问题 HOT 2
- 是否计划支持linux io_uring? HOT 3
- SRPC性能测试问题 HOT 25
- client.Echo start multi thread,how can I start only one thread? HOT 6
- thrift oneway 无法正确解析 HOT 2
- list<bool>和map返回值不能正确处理 HOT 16
- 想问一下srpc会存在粘包问题么? HOT 1
- srpc::ThriftClient 是否可以访问原生thrift的TMultiplexedProcessor HOT 1
- 有2层namespace时,生成代码出错 HOT 3
- 关于一个server有多个service,不能正常访问 HOT 9
- SRPC支持自定义拦截器吗 HOT 11
- SRPC Http客户端与服务端参数不一致问题 HOT 2
- openeuler下编译时会报错C++标准,建议更新C++标准从11到14 HOT 3
- 应该如何正确的报错呢? 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 srpc.