我如何跨preT strace的输出? [英] How do I interpret strace output?

查看:122
本文介绍了我如何跨preT strace的输出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要天寒而我使用strace的应用程序的性能。不过,我真的不知道该如何跨preT各种系统调用strace的发射。其中的几个实例是如下:

I need to profile the performance of an application for which I am using strace. However, I do not really know how to interpret the various system calls the strace emits. Examples of a few of them are below:

(A) lseek(3, 1600, SEEK_SET)                = 1600
(B) write(3, "G_DATA    300        0          "..., 800) = 800
(C) close(3)                                = 0
(D) mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2b600b179000
(E) munmap(0x2b600b179000, 4096)            = 0
(F) fstat(3, {st_mode=S_IFREG|0644, st_size=1600, ...}) = 0

我将不胜感激,如果有人可以简单地用简单的英语从什么(A)这些线路到(F)的真正含义在我来解释/ O,数据传输,性能等意义

I would be grateful if someone could briefly explain in plain English what these lines from (A) to (F) really means in terms of I/O, data transferred, significance on performance etc.

我通过使用strace的手册页去了,但仍然不是很很自信。如果您在其他指针给我读,那将是巨大的。

I went through the man pages of strace but still am not very very confident. If you any other pointers for me to read, that would be great.

我对操作系统的一些背景知识,并了解哪些系统调用,内存,虚拟内存,调度等都是。

I have some background on Operating Systems and understand what system calls, memory, virtual memory, Scheduling, etc. are.

推荐答案

为了了解这些,你必须熟悉POSIX的系统调用。他们是一个用户空间程序使用与内核交互的接口。

In order to understand these, you have to get familiar with the POSIX system calls. They are the interface a user-space program uses to interact with the kernel.

lseek的关闭 MMAP 则munmap FSTAT 都的系统调用并在Linux手册的第2节都记录

lseek, write, close, mmap, munmap and fstat are all system calls and are documented in section 2 of the linux manual.

简而言之, lseek的移动提供的文件描述符的内部指针与位置指向的字节第二个参数,从 SEEK_SET <启动/ code>(开始), SEEK_CUR (当前位置)或 SEEK_END (结束)。任何连续要求在同一个描述符将开始从这一立场采取行动。需要注意的是 lseek的未实现各种描述符 - 它是有道理的磁盘上的文件,而不是一个套接字或管道

Briefly, lseek moves the internal pointer of the supplied file descriptor to the byte with position pointed to by the second argument, starting from SEEK_SET (the beginning), SEEK_CUR (current position) or SEEK_END (the end). Any consecutive read and write calls on the same descriptor will start their action from this position. Note that lseek is not implemented for all kinds of descriptors - it makes sense for a file on disk, but not for a socket or a pipe.

复制提供的缓冲区,内核空间,并返回实际写入的字节数。根据其种类的描述符,内核可将数据写入磁盘或通过网络发送。这通常是一个昂贵的操作,因为它涉及到这个缓冲器传送到所述内核

write copies the supplied buffer to kernelspace and returns the number of bytes actually written. Depending on the kind of the descriptor, the kernel may write the data to disk or send it through the network. This is generally a costly operation because it involves transferring this buffer to the kernel.

关闭关闭所提供的描述符和内核与任何相关的资源被释放。请注意,每个进程都有上同时打开的描述符的数量限制,所以有时需要关闭描述符不达到此限制。

close closes the supplied descriptor and any associated resources with it in the kernel are freed. Note that each process has a limit on the number of simultaneously open descriptors, so it's sometimes necessary to close descriptors to not reach this limit.

MMAP 是一个复杂的系统呼叫,并用于多种目的,包括共享存储器。然而,一般用法是为进程分配更多的内存。在的malloc 释放calloc 库函数通常在内部使用。

mmap is a complex system call and is used for many purposes including shared memory. The general usage however is to allocate more memory for the process. The malloc and calloc library functions usually use it internally.

则munmap 释放 MMAP PED内存。

FSTAT 返回的各种信息,该文件系统保存了有关的文件 - 大小,最后一次修改,权限等

fstat returns various information that the filesystem keeps about a file - size, last modified, permissions, etc.

这篇关于我如何跨preT strace的输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆