Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Linux \ Teach you to diagnose problems with strace     - VNC connection VMware vSphere ESXi 5.5 (Linux)

- CentOS / RHEL 6 was repeated prohibited under the SNMP connection log (Server)

- Linux AS4 VPN server in conjunction with a firewall perfect (Linux)

- Ubuntu 15.04 and CentOS 7 to deploy .NET, Mono and DNX (Server)

- Linux Firewall Basics (Linux)

- OpenSSL: implementation creates a private CA, certificate signing request Explanation (Server)

- Install Firefox 32 official version of the Linux system (Linux)

- Python class of operator overloading (Programming)

- Oracle 12C truncate table cascade (Database)

- Use CutyCapt to convert HTML pages to png images on Linux (Linux)

- MySQL can not write the data keyword conflicts (Database)

- C ++ input and output summary _ Input (Programming)

- Linux Network Programming --epoll model Detailed principles and examples (Programming)

- 24 Docker recommendations (Linux)

- Ten to improve the efficiency of the Linux bash tricks (Linux)

- Android will save the picture to see the album and timely (Programming)

- Oracle 11g R2 RAC RMAN backup script example (Database)

- Oracle PLS-00231 error analysis (Database)

- Python common data type summary (Programming)

- grep command Series: How to Use the grep command in Linux / UNIX (Linux)

  Teach you to diagnose problems with strace
  Add Date : 2017-01-08      
  In earlier years, if you know there strace command, it is cattle, and now we basically know strace, if you experience performance problems to help others, in all likelihood would suggest that you hang with strace to see, but when you hang up, watching the full screen rolling character, but in all likelihood not see what they were. In this paper, a simple case, to show you what some of the repertoire with strace diagnose problems when.

Follows the real case, any similarity, it is inevitable! Let's look at the results of a top high-load servers:


Tip: When you run top, press "1" to open the CPU list, press "shift + p" to sort the CPU.

In this example, we can easily find the main CPU is occupied by a number of PHP processes, while PHP process takes up more memory, but the memory still balances system, SWAP is not serious, this is not the main cause of the problem.

However, the list can be seen in the CPU CPU mainly consumed in kernel mode "sy", rather than the user mode "us" and our experience does not match. Linux operating system has a lot of tools for tracking program behavior, function call tracking kernel mode "strace" user mode tracking function call "ltrace", so here we should use "strace":

shell> strace-p < PID >
However, if the direct use strace to track a process, then wait for your characters tend to be full screen roll and want to be seen from the crux of the problem here is not an easy thing, but fortunately strace can be aggregated by time operation:

shell> strace-cp < PID >
By "c" option to summarize total time of each operation, the result after running roughly as follows:

strace -cp

Obviously, we can see the main CPU clone operation is consumed, you can also track what clone alone:

shell> strace-T -e clone-p < PID >
By "T" option to obtain the actual operating time consumed by "e" option to track an action:

strace -T -e clone -p

Obviously, a clone operation takes a few hundred milliseconds, as clone meaning, reference man documentation:

clone () creates a new process, in a manner similar to fork (2). It is actually a library function layered on top of the underlying clone () system call, hereinafter referred to as sys_clone. A description of sys_clone is given towards the end of this page.

Unlike fork (2), these calls allow the child process to share parts of its execution context with the calling process, such as the memory space, the table of file descriptors, and the table of signal handlers. (Note that on this manual page , "calling process" normally corresponds to "parent process". But see the description of CLONE_PARENT below.)

In simple terms, it is to create a new process. So in PHP when such a system would appear to call it? Discover the business code to see the exec function, the following command to verify that it does cause clone system call:

shell> strace-eclone php -r 'exec ( "ls");'
Finally, we test a question: If we use strace to track a process, very little output, it is not that the process is idle? In fact, try ltrace, may find amazing. Remember the kernel mode and user mode points.
- ApacheDS configuration of users and user groups to achieve SSO (Server)
- Linux Disk and File Management (Linux)
- Linux system man help tips (Linux)
- How to use the beta / unstable version of the software in Debian library (Linux)
- You must ask yourself four questions before deploying Docker (Server)
- MyCAT separate read and write to achieve MySQL Practice (Database)
- Java in several ways of using MongoDB (Programming)
- PostgreSQL export data dictionary documents (Database)
- Ftp user to create multiple virtual machines to support different access rights Examples (Server)
- In Debian 4.3 compiler under Linux-2.6.28 kernel Summary (Programming)
- Arduino UNO simulation development environment set up and run simulation (Linux)
- Hadoop scheduling availability of workflow platform - Oozie (Server)
- Linux security settings Basics (Linux)
- Android Studio 1.0.2 set the memory size (Linux)
- To build PHP environment (Nginx + MariaDB + PHP7) under CentOS 6.5 (Server)
- C # mobile side and PC-side data exchange (Database)
- Linux Shell introduces (Linux)
- The Rabbitmq installation under CentOS 6.4 (Linux)
- ctop: monitor container performance Linux command line artifact (Linux)
- Java static code analysis tool Infer (Programming)
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.