This is an automated email from the ASF dual-hosted git repository.
kxiao pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.0 by this push:
new b1c85b88fdf [LOG](exec) Add timer for hostname_to_ip (#29497) (#29752)
b1c85b88fdf is described below
commit b1c85b88fdff75de0e214a588d741d2b29ba6f32
Author: Kang <[email protected]>
AuthorDate: Wed Jan 10 00:43:16 2024 +0800
[LOG](exec) Add timer for hostname_to_ip (#29497) (#29752)
---
be/src/util/network_util.cpp | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/be/src/util/network_util.cpp b/be/src/util/network_util.cpp
index d80682d21ec..e7953c341d4 100644
--- a/be/src/util/network_util.cpp
+++ b/be/src/util/network_util.cpp
@@ -33,6 +33,7 @@
#include <sys/socket.h>
#include <unistd.h>
+#include <chrono>
#include <sstream>
#ifdef __APPLE__
@@ -78,11 +79,20 @@ bool is_valid_ip(const std::string& ip) {
}
Status hostname_to_ip(const std::string& host, std::string& ip) {
+ auto start = std::chrono::high_resolution_clock::now();
Status status = hostname_to_ipv4(host, ip);
if (status.ok()) {
return status;
}
- return hostname_to_ipv6(host, ip);
+ status = hostname_to_ipv6(host, ip);
+
+ auto current = std::chrono::high_resolution_clock::now();
+ auto duration =
std::chrono::duration_cast<std::chrono::milliseconds>(current - start);
+ if (duration.count() >= 500) {
+ LOG(WARNING) << "hostname_to_ip cost to mush time, cost_time:" <<
duration.count()
+ << "ms hostname:" << host << " ip:" << ip;
+ }
+ return status;
}
Status hostname_to_ip(const std::string& host, std::string& ip, bool ipv6) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]