strace

翻译一篇外文 关于优化linux系统启动时间的文章

我是研究僧i 提交于 2019-12-02 06:09:51
翻译的比较烂,自己记录下。 启动时间最优化 Alexander belloni , Michael Opdenacker Free Electrons 简单的进程信息 简单的最优化分为如下方面讲: 原则 如何测量 用户区域 内核 启动 bootloader 笔记:完成样本镜像,测量启动时间,最优化启动脚本,最优化内核 原则: 1. 减少启动时间意味着首先要测量启动时间 2. 你需要选择启动和停止的参考点,即启动时间开始到结束的点。 一些减少启动时间的意见: 1. 最快的代码是代码没有被执行 2. Boot 的一大部分时间是将代码和数据从存储器搬到 ram 。读取少的代码和数据就会更快。 I/O 操作是耗时的。 3. 文件系统越大加载时间越长。 4. 所以没有运行的代码会让你的启动时间更长 5. 当然不同的存储器都不一样,一般 sd 卡要比 nand 快。 6. 使用 gcc 编译的时候用 -0s 的参数会让代码更小,但是代码将失去一些特性,这也行是一个办法。 学习开发板的影响 学习如何实现它 测量 measuring 1. 最好的仪器是示波器。 2. 测试上电启动时间,这是非常精准的测试方式。 3. 系统启动时写 GPIO 口和存储器是非常简单的。 4. 一些示波器能够负担得起。 5. 通常你不想用示波器,或者不想冒硬件连接的风险。 6. 通常我们通过串口反馈启动时间信息

神器之strace

半城伤御伤魂 提交于 2019-12-02 05:35:14
什么是strace strace是Linux环境下的一款程序调试工具,用来监察一个应用程序所使用的系统调用。 Strace是一个简单的跟踪系统调用执行的工具。在其最简单的形式中,它可以从开始到结束跟踪二进制的执行,并在进程的生命周期中输出一行具有系统调用名称,每个系统调用的参数和返回值的文本行。 在Linux中,进程是不能直接去访问硬件设备的,比如读取磁盘文件、接收网络数据等,但可以将用户态模式切换到内核模式,通过系统调用来访问硬件设备。这时strace就可以跟踪到一个进程产生的系统调用,包括参数,返回值,执行消耗的时间、调用次数,成功和失败的次数。 strace能做什么 它可以基于特定的系统调用或系统调用组进行过滤 它可以通过统计特定系统调用的使用次数,所花费的时间,以及成功和错误的数量来分析系统调用的使用。 它跟踪发送到进程的信号。 可以通过pid附加到任何正在运行的进程。 调试性能问题,查看系统调用的频率,找出耗时的程序段 查看程序读取的是哪些文件从而定位比如配置文件加载错误问题 查看某个php脚本长时间运行“假死”情况 当程序出现“Out of memory”时被系统发出的SIGKILL信息所kill 另外因为strace拿到的是系统调用相关信息,一般也即是IO操作信息,这个对于排查比如cpu占用100%问题是无能为力的。这个时候就可以使用GDB工具了。 phptrace

Linux服务器的16个监控命令

落爺英雄遲暮 提交于 2019-12-02 03:41:06
想不想知道你的服务器到底在干什么?那么你要知道本文介绍的这些基本命令。一旦你熟悉掌握了这些命令,就为成为专业的 Linux系统管理员打下了基础。 你可以通过图形化用户界面(GUI)程序来获取这些外壳命令提供的大量信息,具体取决于使用哪一种Linux发行版。比如说,SUSE Linux就有一款出色的、图形化配置和管理工具YaST,KDE的KDE System Guard同样很出色。 不过,Linux管理员要明白的一个常理是:只有绝对必要时,才应该在服务器上运行GUI。那是由于,Linux GUI耗用系统资源,而这些资源原本可以更合理地用在其他地方。所以,尽管使用GUI程序很适合对服务器健康状况做一个基本的检查,但是如果你想知道到底发生了什么,请关闭GUI,开始从Linux命令外壳使用这些工具。 这还意味着,只要在需要时,你才应该在服务器上开启GUI;不用的时候,就及时关掉。为了确保性能最佳,Linux服务器应该在运行级别(runlevel)3下运行,这个运行级别完全支持网络和多个用户,但是在机器启动时,又不开启GUI。如果你果真需要图形化桌面,总是可以从外壳提示符下运行startx,获得图形化桌面。 如果你的服务器启动后进入到图形化桌面,就需要更改这种情况。为此,进入到终端窗口,使用su命令切换到root用户,然后用你常用的编辑器打开/etc/inittab文件。 一旦进入到文件里面

Slow service response Times : Java SecureRandom & /dev/random

感情迁移 提交于 2019-12-01 17:33:59
问题 I am trying to debug a few slow responses served by an app deployed on Tomcat. Right now I am focussing on SecureRandom and /dev/random (some of the other probable causes have been investigated and ruled out). The pattern is as follows: The first call takes exactly 30.0 xy seconds after Tomcat restart (even if the request arrives 4 minutes after the Startup) Later, some calls take exactly 15.0 pq seconds (there was no specific pattern that I could establish, pq being the time approximate time

【原创】CPU 100%+磁盘写满 问题排查

会有一股神秘感。 提交于 2019-11-30 11:36:21
情景:测试人员在进行 RabbitMQ 服务器问题排查时,进行了各种重启操作,之后突然发现机器变的很卡。 排查过程: 1. 通过 top 查看,发现名为 sa 的进程 CPU 占用率几乎 100% 。 2. 查看 sa 进程中哪个线程占用 CPU 比较高 [root@rmq_2 ~]# top -Hp 1362 top - 05:36:26 up 2 days, 3:08, 2 users, load average: 1.77, 3.69, 5.11 Tasks: 16 total, 0 running, 16 sleeping, 0 stopped, 0 zombie Cpu0 : 0.4%us, 2.8%sy, 0.0%ni, 95.7%id, 0.0%wa, 1.1%hi, 0.0%si, 0.0%st Cpu1 : 0.4%us, 14.7%sy, 0.0%ni, 29.4%id, 53.8%wa, 0.0%hi, 1.8%si, 0.0%st Cpu2 : 0.7%us, 2.1%sy, 0.0%ni, 95.9%id, 0.0%wa, 0.0%hi, 1.4%si, 0.0%st Cpu3 : 0.3%us, 5.8%sy, 0.0%ni, 77.1%id, 16.4%wa, 0.0%hi, 0.3%si, 0.0%st Mem: 3924376k total,

How does strace work?

隐身守侯 提交于 2019-11-30 06:27:16
It can trace all system calls used. But what differs a sys_call from a normal call?? As Matthew said, strace uses the ptrace(2) system call to work its magic. ptrace is used to implement debuggers and other tools which need to inspect what another program is doing. Essentially, strace will call ptrace and attach to a target process. Whenever the target process makes a system call, it will stop, and strace will be notified. strace will then inspect the registers and stack of the target process (also using ptrace) to determine what system call was being made (each call has a unique number,

ltrace equivalent for osx?

白昼怎懂夜的黑 提交于 2019-11-30 04:45:41
osx has the really powerful dtrace/ktrace/dtruss tools - however i'm not willing to invest the time necessary to learn dealing with them right now. what's the easiest way to get the equivalent functionality of linux ltrace (and possibly strace) on OSX? No answer for ltrace (except perhaps "work out how to use dtrace" :-) ), but for system call tracing ala strace, dtruss is a pretty good front end to dtrace. e.g. dtruss df -h # run and examine the "df -h" command dtruss -p 1871 # examine PID 1871 dtruss -n tar # examine all processes called "tar" you don't need to learn dtrace to use it. there

How can I get dtrace to run the traced command with non-root priviledges?

喜欢而已 提交于 2019-11-29 19:57:17
OS X lacks linux's strace , but it has dtrace which is supposed to be so much better. However, I miss the ability to do simple tracing on individual commands. For example, on linux I can write strace -f gcc hello.c to caputre all system calls, which gives me the list of all the filenames needed by the compiler to compile my program (the excellent memoize script is built upon this trick) I want to port memoize on the mac, so I need some kind of strace . What I actually need is the list of files gcc reads and writes into, so what I need is more of a truss . Sure enough can I say dtruss -f gcc

强大的strace命令用法详解

会有一股神秘感。 提交于 2019-11-29 13:19:24
强大的strace命令用法详解 文章转自: https://www.linuxidc.com/Linux/2018-01/150654.htm   strace是什么?   按照strace官网的描述, strace是一个可用于诊断、调试和教学的Linux用户空间跟踪器。我们用它来监控用户空间进程和内核的交互,比如系统调用、信号传递、进程状态变更等。 strace底层使用内核的ptrace特性来实现其功能。   在运维的日常工作中,故障处理和问题诊断是个主要的内容,也是必备的技能。strace作为一种动态跟踪工具,能够帮助运维高效地定位进程和服务故障。它像是一个侦探,通过系统调用的蛛丝马迹,告诉你异常的真相。   strace能做什么?   运维工程师都是实践派的人,我们还是先来个例子吧。   我们从别的机器copy了个叫做some_server的软件包过来,开发说直接启动就行,啥都不用改。可是尝试启动时却报错,根本起不来!   启动命令:   ./some_server ../conf/some_server.conf   输出:   FATAL: InitLogFile failed iRet: -1!   Init error: -1655   为什么起不来呢?从日志看,似乎是初始化日志文件失败,真相到底怎样呢?我们用strace来看看。   strace -tt -f .

How does strace work?

余生颓废 提交于 2019-11-29 06:13:03
问题 It can trace all system calls used. But what differs a sys_call from a normal call?? 回答1: As Matthew said, strace uses the ptrace(2) system call to work its magic. ptrace is used to implement debuggers and other tools which need to inspect what another program is doing. Essentially, strace will call ptrace and attach to a target process. Whenever the target process makes a system call, it will stop, and strace will be notified. strace will then inspect the registers and stack of the target