diff --git a/services/sink/transport/src/distributed_input_sink_transport.cpp b/services/sink/transport/src/distributed_input_sink_transport.cpp index 0025ea3..d7a1574 100644 --- a/services/sink/transport/src/distributed_input_sink_transport.cpp +++ b/services/sink/transport/src/distributed_input_sink_transport.cpp @@ -199,7 +199,7 @@ int32_t DistributedInputSinkTransport::RespLatency(const int32_t sessionId, std: return ERR_DH_INPUT_SERVER_SINK_TRANSPORT_RESP_LATENCY_FAIL; } - DHLOGI("RespLatency sessionId: %d, smsg:%s.", sessionId, SetAnonyId(smsg).c_str()); + DHLOGD("RespLatency sessionId: %d, smsg:%s.", sessionId, SetAnonyId(smsg).c_str()); return DH_SUCCESS; } @@ -234,7 +234,7 @@ void DistributedInputSinkTransport::SendKeyStateNodeMsgBatch(const int32_t sessi } DHLOGI("SendKeyStateNodeMsgBatch sessionId: %d, event size: %d ", sessionId, events.size()); - int64_t currentTimeNs = GetCurrentTime() * 1000LL; + int64_t currentTimeNs = GetCurrentTimeUs() * 1000LL; std::shared_ptr eventsJsonArr = std::make_shared(); for (const auto &ev : events) { nlohmann::json tmpJson; diff --git a/services/source/transport/include/distributed_input_source_transport.h b/services/source/transport/include/distributed_input_source_transport.h index 88bcba6..44f1eac 100644 --- a/services/source/transport/include/distributed_input_source_transport.h +++ b/services/source/transport/include/distributed_input_source_transport.h @@ -147,7 +147,7 @@ private: std::shared_ptr statuslistener_; std::string mySessionName_ = ""; std::condition_variable openSessionWaitCond_; - uint64_t deltaTime_ = 0; + uint64_t deltaTime_ = 0; uint64_t deltaTimeAll_ = 0; uint64_t sendTime_ = 0; uint32_t sendNum_ = 0; diff --git a/services/source/transport/src/distributed_input_source_transport.cpp b/services/source/transport/src/distributed_input_source_transport.cpp index a10823b..8b85e72 100644 --- a/services/source/transport/src/distributed_input_source_transport.cpp +++ b/services/source/transport/src/distributed_input_source_transport.cpp @@ -41,6 +41,7 @@ namespace DistributedHardware { namespace DistributedInput { namespace { const char DHID_SPLIT = '.'; + const uint64_t MSG_LATENCY_ALARM_US = 20; } DistributedInputSourceTransport::~DistributedInputSourceTransport() { @@ -673,7 +674,7 @@ void DistributedInputSourceTransport::StartLatencyCount(const std::string &devic recvNum_ = 0; eachLatencyDetails_ = ""; } - sendTime_ = GetCurrentTime(); + sendTime_ = GetCurrentTimeUs(); LatencyCount(deviceId); sendNum_ += 1; usleep(INPUT_LATENCY_DELAYTIME_US); @@ -1101,10 +1102,13 @@ void DistributedInputSourceTransport::CalculateLatency(int32_t sessionId, const return; } - deltaTime_ = GetCurrentTime() - sendTime_; + deltaTime_ = GetCurrentTimeUs() - sendTime_; deltaTimeAll_ += deltaTime_; recvNum_ += 1; eachLatencyDetails_ += (std::to_string(deltaTime_) + DINPUT_SPLIT_COMMA); + if (deltaTime_ >= MSG_LATENCY_ALARM_US) { + DHLOGW("The RTT time between send req and receive rsp is too long: llu% us"); + } } void DistributedInputSourceTransport::ReceiveSrcTSrcRelayPrepare(int32_t sessionId, const nlohmann::json &recMsg) diff --git a/services/transportbase/src/distributed_input_transport_base.cpp b/services/transportbase/src/distributed_input_transport_base.cpp index 1791dd5..f74e8e6 100644 --- a/services/transportbase/src/distributed_input_transport_base.cpp +++ b/services/transportbase/src/distributed_input_transport_base.cpp @@ -443,7 +443,7 @@ bool DistributedInputTransportBase::CheckRecivedData(const std::string &message) void DistributedInputTransportBase::OnBytesReceived(int32_t sessionId, const void *data, uint32_t dataLen) { - DHLOGI("OnBytesReceived, sessionId: %d, dataLen:%d", sessionId, dataLen); + DHLOGD("OnBytesReceived, sessionId: %d, dataLen:%d", sessionId, dataLen); if (sessionId < 0 || data == nullptr || dataLen <= 0) { DHLOGE("OnBytesReceived param check failed"); return; @@ -462,11 +462,11 @@ void DistributedInputTransportBase::OnBytesReceived(int32_t sessionId, const voi } std::string message(buf, buf + dataLen); - DHLOGI("OnBytesReceived message:%s.", SetAnonyId(message).c_str()); + DHLOGD("OnBytesReceived message:%s.", SetAnonyId(message).c_str()); HandleSession(sessionId, message); free(buf); - DHLOGI("OnBytesReceived completed"); + DHLOGD("OnBytesReceived completed"); return; } @@ -491,7 +491,7 @@ void DistributedInputTransportBase::HandleSession(int32_t sessionId, const std:: DHLOGE("srcCallback is nullptr."); return; } - DHLOGI("HandleSession to source."); + DHLOGD("HandleSession to source."); srcCallback_->HandleSessionData(sessionId, message); return; } @@ -500,7 +500,7 @@ void DistributedInputTransportBase::HandleSession(int32_t sessionId, const std:: DHLOGE("sinkCallback is nullptr."); return; } - DHLOGI("HandleSession to sink."); + DHLOGD("HandleSession to sink."); sinkCallback_->HandleSessionData(sessionId, message); } } diff --git a/utils/include/dinput_utils_tool.h b/utils/include/dinput_utils_tool.h index b41e564..15ab0ad 100644 --- a/utils/include/dinput_utils_tool.h +++ b/utils/include/dinput_utils_tool.h @@ -36,7 +36,7 @@ struct DevInfo { DevInfo GetLocalDeviceInfo(); std::string GetLocalNetworkId(); std::string GetUUIDBySoftBus(const std::string &networkId); -uint64_t GetCurrentTime(); +uint64_t GetCurrentTimeUs(); std::string SetAnonyId(const std::string &message); /* IsString, IsUInt32 and IsUInt64 are used to valid json key */ bool IsBoolean(const nlohmann::json &jsonObj, const std::string &key); diff --git a/utils/src/dinput_utils_tool.cpp b/utils/src/dinput_utils_tool.cpp index ef8b460..ecd2273 100644 --- a/utils/src/dinput_utils_tool.cpp +++ b/utils/src/dinput_utils_tool.cpp @@ -95,7 +95,7 @@ std::string GetUUIDBySoftBus(const std::string &networkId) return (ret == DH_SUCCESS) ? std::string(uuid) : ""; } -uint64_t GetCurrentTime() +uint64_t GetCurrentTimeUs() { constexpr int32_t usOneSecond = 1000 * 1000; struct timeval tv; diff --git a/utils/test/unittest/dinput_context_test.cpp b/utils/test/unittest/dinput_context_test.cpp index e994cbb..7c541d6 100644 --- a/utils/test/unittest/dinput_context_test.cpp +++ b/utils/test/unittest/dinput_context_test.cpp @@ -204,7 +204,7 @@ HWTEST_F(DInputContextTest, GetUUIDBySoftBus_001, testing::ext::TestSize.Level1) HWTEST_F(DInputContextTest, GetCurrentTime_001, testing::ext::TestSize.Level1) { - uint64_t ret = GetCurrentTime(); + uint64_t ret = GetCurrentTimeUs(); EXPECT_NE(0, ret); }