[20190314]使用strace注意的問題.txt
[20190314]使用strace注意的問題.txt
--//使用strace跟蹤程式,我發現我自己忽略一個問題.一般看函式呼叫花費時間一般使用如下引數:
-r Print a relative timestamp upon entry to each system call. This records the time difference between the beginning
of successive system calls.
-t Prefix each line of the trace with the time of day.
-tt If given twice, the time printed will include the microseconds.
-ttt If given thrice, the time printed will include the microseconds and the leading portion will be printed as the
number of seconds since the epoch.
-T Show the time spent in system calls. This records the time difference between the beginning and the end of each
system call.
--//注意-T,-r引數的區別.-T顯示的system calls的時間,顯示在最後.
--//-r 顯示相對時間,顯示在前面.
--//透過例子說明:
$ export TNS_ADMIN=/tmp
--//在tmp目錄下建立如下檔案:
$ cat tnsnames.ora
CLIENT_CON =
(DESCRIPTION =
(LOAD_BALANCE=OFF)
(TRANSPORT_CONNECT_TIMEOUT=1)
(ADDRESS = (PROTOCOL = TCP)(HOST =10.10.10.10)(PORT = 1522))
(ADDRESS = (PROTOCOL = TCP)(HOST =11.11.11.11)(PORT = 1522))
(ADDRESS = (PROTOCOL = TCP)(HOST =12.12.12.12)(PORT = 1522))
(ADDRESS = (PROTOCOL = TCP)(HOST =13.13.13.13)(PORT = 1522))
(ADDRESS = (PROTOCOL = TCP)(HOST =14.14.14.14)(PORT = 1522))
(ADDRESS = (PROTOCOL = TCP)(HOST =15.15.15.15)(PORT = 1522))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orclgg)
))
$ strace -r -tT -f tnsping client_con 2>&1 | grep -C1 -E 'poll'
0.000084 mmap(NULL, 528384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f0c2342a000 <0.000023>
0.000078 poll([{fd=4, events=POLLOUT}], 1, 1000) = 0 (Timeout) <1.001095>
1.001171 close(4) = 0 <0.000076>
--
0.000122 times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 10709770534 <0.000027>
0.000085 poll([{fd=4, events=POLLOUT}], 1, 1000) = 0 (Timeout) <1.001072>
1.001181 close(4) = 0 <0.000111>
--
0.000128 times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 10709770634 <0.000026>
0.000084 poll([{fd=4, events=POLLOUT}], 1, 1000) = 0 (Timeout) <1.001086>
1.001340 close(4) = 0 <0.000055>
--
0.000126 times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 10709770735 <0.000056>
0.000116 poll([{fd=4, events=POLLOUT}], 1, 1000) = 0 (Timeout) <1.001093>
1.001261 close(4) = 0 <0.000080>
--
0.000125 times({tms_utime=1, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 10709770835 <0.000027>
0.000084 poll([{fd=4, events=POLLOUT}], 1, 1000) = 0 (Timeout) <1.001079>
1.001265 close(4) = 0 <0.000082>
--
0.000120 times({tms_utime=1, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 10709770935 <0.000027>
0.000085 poll([{fd=4, events=POLLOUT}], 1, 1000) = 0 (Timeout) <1.001085>
1.001255 close(4) = 0 <0.000055>
--//說明-C1,顯示匹配poll前後1行.
--//另外可以發現-t顯示時間的引數如下,在使用-r引數時.
--//-r顯示的時間在前面,不可能close花費1秒,實際上poll呼叫後,呼叫close前的時間.
--//-T顯示的時間在後面,這個是system call花費的時間.
--//注意這些區別對於診斷問題幫助很大.遇到不熟悉的函式可以使用man檢視,比如:
$ man poll
POLL(2) Linux Programmer's Manual POLL(2)
NAME
poll, ppoll - wait for some event on a file descriptor
SYNOPSIS
#include <poll.h>
int poll(struct pollfd *fds, nfds_t nfds, int timeout);
#define _GNU_SOURCE
#include <poll.h>
int ppoll(struct pollfd *fds, nfds_t nfds,
const struct timespec *timeout, const sigset_t *sigmask);
DESCRIPTION
poll() performs a similar task to select(2): it waits for one of a set of file descriptors to become ready to perform I/O.
The set of file descriptors to be monitored is specified in the fds argument, which is an array of nfds
structures of the following form:
struct pollfd {
int fd; /* file descriptor */
short events; /* requested events */
short revents; /* returned events */
};
The field fd contains a file descriptor for an open file.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2638331/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- [20181217]strace使用問題.txt
- [20200402]strace過濾使用awk問題.txt
- [20181227]bbed的使用問題.txt
- 使用 sendBeacon 需要注意的問題
- Promise使用時應注意的問題Promise
- [20211229]toad下優化sql語句注意的問題.txt優化SQL
- 面試官:集合使用時應該注意哪些問題?我:應該注意該注意的問題!面試
- [20210303]bbed使用小問題.txt
- [20220121]windows使用grep注意.txtWindows
- [20210408]使用linux find注意.txtLinux
- 使用 foreach 使用引用變數需要注意的問題變數
- [20211220]記錄使用sqlplus的小問題.txtSQL
- [20190221]使用nmap掃描埠的問題.txt
- [20180420]windows下使用cmd的小問題.txtWindows
- [20210902]cut使用輸出問題.txt
- [20200227]使用tcpdump or and ()語法問題.txtTCP
- 使用System.IO.File.Create()時注意的問題
- [20200219]strace跟蹤設定ENABLE=BROKEN的情況.txt
- [20240309]在windwos下使用sed遇到的問題.txt
- strace解決sqlplus登陸緩慢的問題一例SQL
- [20221010]使用toad管理索引改名問題.txt索引
- [20191118]使用Chrome瀏覽器問題.txtChrome瀏覽器
- [20220324]toad與sql profile使用問題.txtSQL
- [20181119]使用sql profile優化問題.txtSQL優化
- [20180412]logminer使用問題(10g).txt
- angular注意問題Angular
- 電磁流量計在使用需要注意的問題
- [20231029]使用cygwin調式bash shell引出的問題.txt
- [20190929]bash使用bc計算的相關問題.txt
- [20220102]使用ashtop與dashtop指令碼的小問題.txt指令碼
- [20211221]記錄使用sqlplus的小問題補充.txtSQL
- 使用strace來查詢php的坑PHP
- [20221101]tmux使用問題copy和paste失效.txtUXAST
- [20190116]rman的老問題.txt
- Redux的應該注意的問題Redux
- [20190320]關於使用smem檢視記憶體使用的問題.txt記憶體
- [20241110]使用xto10.sql指令碼遇到的問題.txtSQL指令碼
- Oracle最佳化案例-strace sqlplus定位網路問題(三十一)OracleSQL