Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Linux \ Teach you to diagnose problems with strace     - Oracle database with test data insertion speed (Database)

- TypeScript basic grammar (Programming)

- Ubuntu manually set the DSL broadband connection (Linux)

- Ubuntu 14.04 / 14.10 how to install FFmpeg 2.5.1 (Linux)

- The free command in Linux (Linux)

- Linux System Getting Started Learning: the curl set custom HTTP header (Linux)

- Linux kernel socket protocol stack routing lookup cache mechanism (Linux)

- Install VLC player on Ubuntu 14.10 (Linux)

- Intel Graphics Installer 1.0.3 released, support for Ubuntu (Linux)

- Install and configure GO 1.2.1 under CentOS 6.5 (Linux)

- Through eight skills to let you become a super Linux end-user (Linux)

- How do you prevent other users from accessing your home directory in Linux (Linux)

- Oracle Database routine inspection (Database)

- How to install CentOS 7.x in OpenERP (Odoo) (Linux)

- Oracle EBS R12 for Linux installation (Database)

- Zombie process under Linux (Linux)

- PHP parsing algorithm of the interview questions (Programming)

- CentOS 7 source code to compile and install Nginx process record (Server)

- How to configure MariaDB replication in CentOS Linux (Database)

- A key installation Gitlab 7 on RHEL6.4 and Setup Mail TX (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:

top

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.
     
         
         
         
  More:      
 
- Linux performance monitoring (Linux)
- TOAST function in PostgreSQL (Database)
- Linux firewall settings -DNS server articles (Server)
- Linux file permissions chmod chown (Linux)
- Using FTPClient to upload and download files in Java (Programming)
- GoldenGate update is missing (Database)
- installation of Vim plugin YouCompleteMe under Ubuntu 15.04 (Linux)
- Each catalog Detailed Linux (Linux)
- Intrusion analysis and prevention tools Knark under Linux platform (Linux)
- Linux development management utility command (Linux)
- After SSH change the default port, how to use Git (Linux)
- CentOS 6.6 x64 Oracle Database 11gR2 RAC automated installation scripts (Database)
- How to manage and use Logical Volume Management LVM in Ubuntu (Linux)
- Linux serial port driver test (Linux)
- How to find on Linux and delete duplicate files: FSlint (Linux)
- Linux PXE unattended installation PXE-E32: TFTP OPen timeout the solution (Linux)
- JEdit 5.2 Pro Edition installation on Ubuntu 14.04 (Linux)
- JavaScript Advanced Programming notes event capture and event bubbling (Programming)
- Docker in the development and practice of IFTTT (Server)
- Ubuntu is expected to allow you to install the latest Nvidia Linux drivers easier (Linux)
     
           
     
  CopyRight 2002-2020 newfreesoft.com, All Rights Reserved.