在Linux下做性能分析3:perf - 知乎 https://zhuanlan.zhihu.com/p/22194920

Linux Perf 性能分析工具及火焰图浅析 - 知乎 https://zhuanlan.zhihu.com/p/54276509

perf record -a -g -e cycles -e cs #系统整体采样

查看指定进程

redis-server

perf report --pid 7070

mysqld

perf report --pid 5634

Samples: 25K of event 'cs', Event count (approx.): 463138
Children Self Command Shared Object Symbol
0.04% 0.00% mysqld [unknown] [.] 0xffffffff83b100f0 ▒
0.04% 0.00% mysqld [unknown] [.] 0xffffffff83b0fbd6 ▒
0.04% 0.00% mysqld [unknown] [.] 0xffffffff83b0de8b ▒
0.04% 0.00% mysqld [unknown] [.] 0xffffffff83b0d1a6 ▒
0.03% 0.00% mysqld mysqld [.] os_event::wait_time_low ▒
0.03% 0.00% mysqld libpthread-2.17.so;5d9ff4e7 (deleted) [.] 0x00007f23ef6b0d12 ◆
0.02% 0.00% mysqld mysqld [.] lock_wait_timeout_thread ▒
0.01% 0.00% mysqld mysqld [.] thd_prepare_connection ▒
0.01% 0.00% mysqld mysqld [.] check_connection ▒
0.01% 0.00% mysqld mysqld [.] acl_authenticate ▒
0.01% 0.00% mysqld mysqld [.] do_auth_once ▒
0.01% 0.00% mysqld mysqld [.] native_password_authenticate ▒
0.01% 0.00% mysqld mysqld [.] server_mpvio_read_packet ▒
0.01% 0.00% mysqld mysqld [.] parse_client_handshake_packet ▒
0.01% 0.00% mysqld libpthread-2.17.so;5d9ff4e7 (deleted) [.] 0x00007f23ef6b0965 ▒
0.01% 0.00% mysqld mysqld [.] srv_master_thread ▒
0.01% 0.00% mysqld libpthread-2.17.so;5d9ff4e7 (deleted) [.] 0x00007f23ef6b3e3d ▒
0.01% 0.00% mysqld [unknown] [.] 0xffffffff83ac6d36 ▒
0.01% 0.00% mysqld [unknown] [.] 0xffffffff83ac6bdb ▒
0.01% 0.00% mysqld [unknown] [.] 0xffffffff84167f06 ▒
0.01% 0.00% mysqld mysqld [.] buf_flush_page_cleaner_coordinator ▒
0.01% 0.00% mysqld mysqld [.] sslaccept ▒
0.01% 0.00% mysqld mysqld [.] yaSSL_accept ▒
0.00% 0.00% mysqld mysqld [.] srv_monitor_thread ▒
0.00% 0.00% mysqld libc-2.17.so;5d9ff4e7 (deleted) [.] 0x00007f23ee08a3d5 ▒
0.00% 0.00% mysqld mysqld [.] mysqld_main ▒
0.00% 0.00% mysqld [unknown] [.] 0xffffffff8416813d ▒
0.00% 0.00% mysqld mysqld [.] srv_error_monitor_thread ▒
3793a0 3793b0 g std::string::_Rep::_M_dispose@plt ▒

Samples: 159K of event 'cpu-clock', Event count (approx.): 39969500000
Children Self Command Shared Object Symbol
+ 0.72% 0.00% mysqld libpthread-2.17.so;5d9ff4e7 (deleted) [.] 0x00007f23ef6acdd5
+ 0.71% 0.00% mysqld mysqld [.] pfs_spawn_thread
+ 0.71% 0.00% mysqld mysqld [.] handle_connection
+ 0.60% 0.00% mysqld mysqld [.] thd_prepare_connection
+ 0.60% 0.00% mysqld mysqld [.] check_connection
+ 0.60% 0.00% mysqld mysqld [.] acl_authenticate
+ 0.60% 0.00% mysqld mysqld [.] do_auth_once
+ 0.60% 0.00% mysqld mysqld [.] native_password_authenticate
+ 0.60% 0.00% mysqld mysqld [.] server_mpvio_read_packet
+ 0.60% 0.00% mysqld mysqld [.] parse_client_handshake_packet
+ 0.60% 0.00% mysqld mysqld [.] sslaccept
+ 0.58% 0.00% mysqld mysqld [.] TaoCrypt::a_exp_b_mod_c
+ 0.58% 0.00% mysqld mysqld [.] TaoCrypt::AbstractRing::Exponentiate
+ 0.58% 0.00% mysqld mysqld [.] TaoCrypt::ModularArithmetic::SimultaneousExponentiate
+ 0.58% 0.00% mysqld mysqld [.] TaoCrypt::AbstractGroup::SimultaneousMultiply
+ 0.54% 0.00% mysqld mysqld [.] yaSSL_accept
0.47% 0.00% mysqld mysqld [.] yaSSL::sendServerKeyExchange
0.47% 0.00% mysqld mysqld [.] yaSSL::ServerKeyExchange::build
0.47% 0.00% mysqld mysqld [.] yaSSL::DH_Server::build
0.47% 0.00% mysqld mysqld [.] TaoCrypt::MontgomeryRepresentation::Square
0.47% 0.00% mysqld mysqld [.] TaoCrypt::RSA_PublicKey::ApplyFunction
0.47% 0.00% mysqld mysqld [.] yaSSL::RSA::sign
0.47% 0.00% mysqld mysqld [.] TaoCrypt::RSA_Encryptor<TaoCrypt::RSA_BlockType1>::Encrypt
0.36% 0.00% mysqld mysqld [.] TaoCrypt::MontgomeryReduce
0.32% 0.03% mysqld mysqld [.] TaoCrypt::RecursiveMultiply
0.27% 0.24% mysqld mysqld [.] TaoCrypt::Portable::Multiply8
0.18% 0.01% mysqld mysqld [.] TaoCrypt::RecursiveMultiplyTop
0.17% 0.01% mysqld mysqld [.] TaoCrypt::RecursiveSquare
0.15% 0.00% mysqld mysqld [.] TaoCrypt::RecursiveMultiplyBottom
0.14% 0.13% mysqld mysqld [.] TaoCrypt::Portable::Add
0.10% 0.00% mysqld mysqld [.] TaoCrypt::MontgomeryRepresentation::Multiply
0.10% 0.00% mysqld mysqld [.] do_command
0.10% 0.00% mysqld mysqld [.] TaoCrypt::AbstractRing::MultiplicativeGroupT::Accumulate
0.08% 0.00% mysqld mysqld [.] dispatch_command
0.08% 0.00% mysqld mysqld [.] yaSSL::processReply
Tip: System-wide collection from all CPUs: perf record -a

Samples: 159K of event 'cpu-clock', Event count (approx.): 39969500000
Children Self Command Shared Object Symbol
0.00% 0.00% nginx [unknown] [.] 0xffffffff8417a6e8 ◆
0.00% 0.00% nginx [unknown] [.] 0xffffffff83aa13f5 ▒
0.00% 0.00% nginx [unknown] [.] 0xffffffff83a2e675 ▒
0.00% 0.00% nginx [unknown] [.] 0xffffffff8417932c ▒
0.00% 0.00% nginx [unknown] [.] 0xffffffff84175ddb ▒
0.00% 0.00% nginx [unknown] [.] 0x64222c3030323a22 ▒
0.00% 0.00% nginx [unknown] [.] 0x000055d5cf29c5d0 ▒
0.00% 0.00% nginx [unknown] [k] 0x0000000000000019 ▒
0.00% 0.00% nginx libpthread-2.17.so;5d9ff4e7 (deleted) [.] 0x00007f304e9c4680 ▒
0.00% 0.00% nginx [unknown] [.] 0xffffffff83c426af ▒
0.00% 0.00% nginx [unknown] [.] 0xffffffff83c41890 ▒
0.00% 0.00% nginx [unknown] [.] 0xffffffff83c40da3 ▒
0.00% 0.00% nginx [unknown] [.] 0xffffffffc04c1322 ▒
0.00% 0.00% nginx [unknown] [.] 0xffffffff83bb8e89 ▒
0.00% 0.00% nginx [unknown] [.] 0xffffffff83bb8c12 ▒
0.00% 0.00% nginx [unknown] [.] 0xffffffff83aa1075 ▒
0.00% 0.00% nginx [kernel.kallsyms] [k] run_timer_softirq ▒
0.00% 0.00% nginx libz.so.1.2.7 [.] 0x000000000000388e ▒
0.00% 0.00% nginx libz.so.1.2.7 [.] crc32 ▒
0.00% 0.00% nginx [unknown] [k] 0x000055d5cf29c6f0 ▒
0.00% 0.00% nginx [unknown] [.] 0x000055d5cf1847e8 ▒
0.00% 0.00% nginx libz.so.1.2.7 [.] 0x00007f304dc3688e ▒
0.00% 0.00% nginx [kernel.kallsyms] [k] do_get_write_access ▒
0.00% 0.00% nginx [kernel.kallsyms] [k] eth_type_trans ▒
0.00% 0.00% nginx [kernel.kallsyms] [k] radix_tree_descend ▒
0.00% 0.00% nginx [kernel.kallsyms] [k] copy_user_enhanced_fast_string ▒
0.00% 0.00% nginx [kernel.kallsyms] [k] __x86_indirect_thunk_rax ▒
0.00% 0.00% nginx [kernel.kallsyms] [k] _raw_spin_unlock_irqrestore ▒
0.00% 0.00% nginx [kernel.kallsyms] [k] check_for_new_grace_period.isra.26 ▒
0.00% 0.00% nginx [kernel.kallsyms] [k] __do_softirq ▒
0.00% 0.00% nginx nginx [.] ngx_http_create_request ▒
0.00% 0.00% nginx [kernel.kallsyms] [k] sys_epoll_ctl ▒
0.00% 0.00% nginx nginx [.] 0x0000000000067287 ▒
0.00% 0.00% nginx nginx [.] 0x000000000007a501 ▒
0.00% 0.00% nginx libz.so.1.2.7 [.] 0x0000000000002c52

Samples: 159K of event 'cpu-clock', 4000 Hz, Event count (approx.): 39969500000
TaoCrypt::Portable::Add /usr/sbin/mysqld [Percent: local period]
3.48 │ lea 0x1(%r8),%r9d ▒
3.48 │ mov (%rdx,%r9,8),%rbx ▒
│ _ZN8TaoCrypt5DWordplEm(): ▒
3.48 │ mov %rbx,%r10 ▒
2.99 │ add (%rsi,%r9,8),%r10 ▒
3.48 │ add %r10,%r11 ▒
4.48 │ setb %r12b ▒
6.97 │ xor %eax,%eax ▒
1.49 │ cmp %r10,%rbx ▒
1.00 │ seta %al ▒
│ _ZN8TaoCrypt8Portable3AddEPmPKmS3_j(): ▒
7.96 │ add $0x2,%r8d ▒
0.50 │ mov %r11,(%rdi,%r9,8) ▒
│ _ZN8TaoCrypt5DWordplEm(): ▒
1.99 │ add %r12,%rax ▒
│ _ZN8TaoCrypt8Portable3AddEPmPKmS3_j(): ▒
3.48 │ cmp %r8d,%ecx ▒
│ → ja 1318f70 <TaoCrypt::Portable::Add(unsigned long*, unsigned long const*, unsigned long const*, unsigned int)+0x10> ▒
0.50 │ pop %rbx ▒
│ pop %r12 ▒
│ pop %rbp ▒
│ ← retq ▒
│ DWord(): ▒
│ xor %eax,%eax ▒
│ ← retq ▒

Samples: 159K of event 'cpu-clock', 4000 Hz, Event count (approx.): 39969500000
TaoCrypt::Portable::Add /usr/sbin/mysqld [Percent: local period]
Percent│ ◆
│ ▒
│ ▒
│ Disassembly of section .text: ▒
│ ▒
│ 0000000001318f60 <TaoCrypt::Portable::Add(unsigned long*, unsigned long const*, unsigned long const*, unsigned int)>: ▒
│ _ZN8TaoCrypt8Portable3AddEPmPKmS3_j(): ▒
1.49 │ test %ecx,%ecx ▒
│ → je 1318fd0 <TaoCrypt::Portable::Add(unsigned long*, unsigned long const*, unsigned long const*, unsigned int)+0x70> ▒
│ push %rbp ▒
│ DWord(): ▒
│ xor %eax,%eax ▒
│ _ZN8TaoCrypt8Portable3AddEPmPKmS3_j(): ▒
│ xor %r8d,%r8d ▒
│ mov %rsp,%rbp ▒
1.49 │ push %r12 ▒
3.48 │ push %rbx ▒
5.47 │ mov %r8d,%r10d ▒
│ _ZN8TaoCrypt5DWordplEm(): ▒
1.49 │ xor %r11d,%r11d ▒
│ _ZN8TaoCrypt8Portable3AddEPmPKmS3_j(): ▒
1.49 │ mov (%rdx,%r10,8),%rbx ▒
│ _ZN8TaoCrypt5DWordplEm(): ▒
3.98 │ mov %rbx,%r9 ▒
1.00 │ add (%rsi,%r10,8),%r9 ▒
1.49 │ add %r9,%rax ▒
3.48 │ setb %r11b ▒
4.98 │ cmp %r9,%rbx ▒
│ _ZN8TaoCrypt8Portable3AddEPmPKmS3_j(): ▒
3.98 │ mov %rax,(%rdi,%r10,8) ▒
│ _ZN8TaoCrypt5DWordplEm(): ▒
5.97 │ seta %r9b ▒
6.47 │ xor %r12d,%r12d ▒
2.49 │ movzbl %r9b,%r9d ▒
5.97 │ add %r9,%r11 ▒
Press 'h' for help on key bindings ▒

深入理解Windows X64调试 - _懒人 - 博客园 https://www.cnblogs.com/lanrenxinxin/p/4762858.html

X86-64寄存器和栈帧 - 为程序员服务 http://ju.outofmemory.cn/entry/769

x86寄存器问题 - wang010366的专栏 - CSDN博客 https://blog.csdn.net/wang010366/article/details/52015264

x64 Architecture - Windows drivers | Microsoft Docs https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/x64-architecture

#include <stdio.h>
#include <malloc.h> int my_stack_heap(void){
/*在栈上分配*/
int i1=0;
int i2=0;
int i3=0;
int i4=0;
printf("---");
printf("栈:向下 i1=0x%08x,i2=0x%08x,i3=0x%08x,i4=0x%08x,\n",&i1,&i2,&i3,&i4);
/*在堆上分配*/
char *p1 = (char *)malloc(256);
char *p2 = (char *)malloc(256);
char *p3 = (char *)malloc(256);
char *p4 = (char *)malloc(256);
printf("堆:向上 p1=0x%08x,p2=0x%08x,p3=0x%08x,p4=0x%08x,\n",p1,p2,p3,p4);
/*释放堆内存*/
free(p1);
p1=NULL;
free(p2);
p2=NULL;
free(p3);
p3=NULL;
free(p4);
p4=NULL; /* 栈:向下
i1=0x0022fe2c
i2=0x0022fe28
i3=0x0022fe24
i4=0x0022fe20 -------------------- p1=0x004bfe40
p2=0x004bfe60
p3=0x004bfe80
p4=0x004bfea0
堆:向上 */
return 0;
}
int main(void) {
while (1==1)
{
/* code */
my_stack_heap();
} return 0;
}

gcc my_stack_heap.c -o my_stack_heap

  

Registers

x64 extends x86's 8 general-purpose registers to be 64-bit, and adds 8 new 64-bit registers. The 64-bit registers have names beginning with "r", so for example the 64-bit extension of eax is called rax. The new registers are named r8 through r15.

The lower 32 bits, 16 bits, and 8 bits of each register are directly addressable in operands. This includes registers, like esi, whose lower 8 bits were not previously addressable. The following table specifies the assembly-language names for the lower portions of 64-bit registers.

性能分析 函数粒度 函数里的一条语句 汇编 反编译 机器指令 %rbx,%rbp的更多相关文章

  1. PHP 性能分析与实验(二)——PHP 性能的微观分析

    [编者按]此前,阅读过了很多关于 PHP 性能分析的文章,不过写的都是一条一条的规则,而且,这些规则并没有上下文,也没有明确的实验来体现出这些规则的优势,同时讨论的也侧重于一些语法要点.本文就改变 P ...

  2. SQL语句性能分析

    SQL语句性能分析 explain执行计划 用法: explain select 语句 命令: show database; use mysql explain select * from user; ...

  3. mysql性能分析show profile/show profiles

    MySQL性能分析show profiles show profile 和 show profiles 语句可以展示当前会话(退出session后,profiling重置为0) 中执行语句的资源使用情 ...

  4. MP实战系列(十六)之性能分析插件

    性能分析拦截器,用于输出每条 SQL 语句及其执行时间. 虽然使用阿里的Druid连接池可以完成这个目的,但是,我们一般认为,目前的组件能够达到这个目的,尽量使用目前的组件,因为修改配置和引入第三方库 ...

  5. PHP函数的实现原理及性能分析

    前言 在任何语言中,函数都是最基本的组成单元.对于php的函数,它具有哪些特点?函数调用是怎么实现的?php函数的性能如何,有什么使用建议?本文将从原理出发进行分析结合实际的性能测试尝试对这些问题进行 ...

  6. PHP 基础系列(三) 【转】PHP 函数实现原理及性能分析

    作者:HDK (百度) 前言 在任何语言中,函数都是最基本的组成单元.对于PHP的函数,它具有哪些特点?函数调用是怎么实现的?php函数的性能如何,有什么使用建议?本文将从原理出发进行分析结合实际的性 ...

  7. (转)PHP 函数的实现原理及性能分析

    前言 任何语言中,函数都是最基本的组成单元.对于php的函数,它具有哪些特点?函数调用是怎么实现的?php函数的性能如何,有什么使用建议?本文 将从原理出发进行分析结合实际的性能测试尝试对这些问题进行 ...

  8. Spring AOP在函数接口调用性能分析及其日志处理方面的应用

    面向切面编程可以实现在不修改原来代码的情况下,增加我们所需的业务处理逻辑,比如:添加日志.本文AOP实例是基于Aspect Around注解实现的,我们需要在调用API函数的时候,统计函数调用的具体信 ...

  9. JS 函数的柯里化与反柯里化

    ===================================== 函数的柯里化与反柯里化 ===================================== [这是一篇比较久之前的总 ...

随机推荐

  1. ansible之基础篇(二)

    软件相关模块 yum rpm和yum的区别 rpm:redhat package manager yum 可以解决依赖关系 yum 源配置 使用yum下载时需要先下载epel [epel] name= ...

  2. PHP标记风格,编码规范

    PHP标记风格PHP一共支持4种标记风格 <?php echo "这是XML风格的标记"; ?> 脚本风格 <script language="php& ...

  3. Flink原理(七)——动态表(Dynamic tables)

    前言 本文是结合Flink官网,个人理解所得,若是有误欢迎留言指出,谢谢!文中图皆来自官网(链接[1]). 本文将随着下面这个问题展开,针对该问题更为生动的解释可以参见金竹老师的分享(链接[2]). ...

  4. Intel虚拟化技术——EPT、VPID

    背景 内存用于暂存CPU将要执行的指令和数据,所有程序的运行都必须先载入到内存中才可以,内存的大小及其访问速度也直接影响整个系统性能.在平台虚拟化技术中,Guest的运行也需要依赖内存.和运行在真实物 ...

  5. IDEA -01 -忽略指定文件夹 -防止加载Vue-cli执行"npm install"命令后的项目时卡死

    问题描述 Vue的"npm install" 命令执行后,会生成一个很大的目录层次的"node_modules",文件十分繁多; idea加载这个项目下的文件夹 ...

  6. unsupervised learning: clustering介绍

    unsupervised learning 上面是监督学习与无监督学习的比较,监督学习的training set是一组带label(y)的训练集,而无监督学习不带有label(y). 上图中的监督学习 ...

  7. 结构型模式(五) 外观模式(Facade)

    一.动机(Motivate) 在软件系统开发的过程中,当组件的客户(即外部接口,或客户程序)和组件中各种复杂的子系统有了过多的耦合,随着外部客户程序和各子系统的演化,这种过多的耦合面临很多变化的挑战. ...

  8. 更改intellij高亮字体背景颜色

    intellij工具中依次进入file -> settings -> editor -> colors & fonts -> general,在右侧窗口中将result ...

  9. Linux - 运行 django 时 :django.db.utils.Notsupportederror: urls not supported

    运行 django 是异常:django.db.utils.Notsupportederror: urls not supported 原因:sqlite3版本3.7的问题 解决:直接改源码 1. p ...

  10. 常见的 eslint 基本报错信息

    Missing semicolon 缺少分号 Missing space before opening brace 左大括号前缺少空格 Trailing spaces not allowed 不允许尾 ...