From fd7283e30f74fad05635bc62158b7e89208e7491 Mon Sep 17 00:00:00 2001 From: Shuo Chen Date: Wed, 10 May 2023 05:43:08 +0000 Subject: [PATCH 1/3] tcpperf show bytes in flight instead of delivery rate. --- tpc/bin/tcpperf.cc | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/tpc/bin/tcpperf.cc b/tpc/bin/tcpperf.cc index f9c43f5..a61f960 100644 --- a/tpc/bin/tcpperf.cc +++ b/tpc/bin/tcpperf.cc @@ -176,8 +176,6 @@ class BandwidthReporter struct tcp_info tcpi = getTcpInfo(fd_); - // bytes_in_flight = tcpi.tcpi_bytes_sent - tcpi.tcpi_bytes_acked; - // tcpi.tcpi_notsent_bytes; int snd_cwnd = tcpi.tcpi_snd_cwnd; int ssthresh = tcpi.tcpi_snd_ssthresh; #ifdef __linux @@ -190,22 +188,25 @@ class BandwidthReporter int retrans = tcpi.tcpi_total_retrans; // int ca_state = tcpi.tcpi_ca_state; int64_t pacing = tcpi.tcpi_pacing_rate; - int64_t delivery = tcpi.tcpi_delivery_rate; + //int64_t delivery = tcpi.tcpi_delivery_rate; + int bytes_in_flight = tcpi.tcpi_bytes_sent - tcpi.tcpi_bytes_acked + 1; // SYN + // tcpi.tcpi_notsent_bytes; #elif __FreeBSD__ int retrans = tcpi.tcpi_snd_rexmitpack; // int ca_state = tcpi.__tcpi_ca_state; int64_t pacing = 0; - int64_t delivery = 0; + //int64_t delivery = 0; + int bytes_in_flight = 0; #endif int retr = retrans - last_retrans_; last_retrans_ = retrans; printf("%6s ", formatSI(pacing).c_str()); - printf("%6s ", formatSI(delivery).c_str()); + printf("%6sB ", formatIEC(bytes_in_flight).c_str()); printf("%6s ", formatIEC(snd_cwnd).c_str()); printf("%6s ", formatIEC(tcpi.tcpi_snd_wnd).c_str()); printf("%6s ", formatIEC(sndbuf).c_str()); - printf("%7s ", formatIEC(ssthresh).c_str()); + printf("%6sB ", formatIEC(ssthresh).c_str()); // printf("%2d ", ca_state); printf("%5d ", retr); printf("%s/%s", formatMicrosecond(tcpi.tcpi_rtt).c_str(), @@ -268,7 +269,7 @@ void runClient(const InetAddress& serverAddr, int64_t bytes_limit, stream->getPeerAddr().toIpPort().c_str(), tcpi.tcpi_snd_mss, cong); } - printf("Time (s) Transfer Bitrate Pacing Delivery Cwnd Rwnd sndbuf ssthresh Retr rtt/var\n"); + printf("Time (s) Transfer Bitrate Pacing InFlight Cwnd Rwnd sndbuf ssthresh Retr rtt/var\n"); const Timestamp start = Timestamp::now(); const int block_size = 64 * 1024; From 1b2cc048a31dd5fd26b712e7253361b1867f45eb Mon Sep 17 00:00:00 2001 From: Shuo Chen Date: Tue, 9 May 2023 22:54:41 -0700 Subject: [PATCH 2/3] fix calculation for bytes_in_flight in case of retransmit. --- tpc/bin/tcpperf.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tpc/bin/tcpperf.cc b/tpc/bin/tcpperf.cc index a61f960..2b84e85 100644 --- a/tpc/bin/tcpperf.cc +++ b/tpc/bin/tcpperf.cc @@ -189,7 +189,7 @@ class BandwidthReporter // int ca_state = tcpi.tcpi_ca_state; int64_t pacing = tcpi.tcpi_pacing_rate; //int64_t delivery = tcpi.tcpi_delivery_rate; - int bytes_in_flight = tcpi.tcpi_bytes_sent - tcpi.tcpi_bytes_acked + 1; // SYN + int bytes_in_flight = tcpi.tcpi_bytes_sent - tcpi.tcpi_bytes_acked - tcpi.tcpi_bytes_retrans + 1; // SYN // tcpi.tcpi_notsent_bytes; #elif __FreeBSD__ int retrans = tcpi.tcpi_snd_rexmitpack; From 284a76a86d5000d0b09d100907eb686020f05327 Mon Sep 17 00:00:00 2001 From: annidy Date: Sat, 23 Sep 2023 20:28:26 +0800 Subject: [PATCH 3/3] support apple platfrom --- .gitignore | 1 + thread/Thread.cc | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/.gitignore b/.gitignore index e4e2791..cfbdabb 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ *.out profile*.pb.gz core +*.dSYM \ No newline at end of file diff --git a/thread/Thread.cc b/thread/Thread.cc index 4909cd0..e32851b 100644 --- a/thread/Thread.cc +++ b/thread/Thread.cc @@ -15,6 +15,8 @@ #if __FreeBSD__ #include +#elif __APPLE__ +#include #else #include #include @@ -37,6 +39,11 @@ pid_t gettid() { return pthread_getthreadid_np(); } +#elif __APPLE__ +pid_t gettid() +{ + return mach_thread_self(); +} #else #if !__GLIBC_PREREQ(2,30) pid_t gettid() @@ -96,6 +103,8 @@ struct ThreadData #if __FreeBSD__ // setname_np() costs as much as creating a thread on FreeBSD 13. pthread_setname_np(pthread_self(), muduo::CurrentThread::t_threadName); +#elif __APPLE__ + pthread_setname_np(muduo::CurrentThread::t_threadName); #else ::prctl(PR_SET_NAME, muduo::CurrentThread::t_threadName); #endif