CN111813677B - 一种嵌入式设备上的性能调试方法 - Google Patents

一种嵌入式设备上的性能调试方法 Download PDF

Info

Publication number
CN111813677B
CN111813677B CN202010655576.7A CN202010655576A CN111813677B CN 111813677 B CN111813677 B CN 111813677B CN 202010655576 A CN202010655576 A CN 202010655576A CN 111813677 B CN111813677 B CN 111813677B
Authority
CN
China
Prior art keywords
function
performance
acquisition
data
entry
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202010655576.7A
Other languages
English (en)
Other versions
CN111813677A (zh
Inventor
徐波
岳坚
张少倩
汤婷
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hangzhou Youwan Technology Co ltd
Original Assignee
Hangzhou Youwan Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hangzhou Youwan Technology Co ltd filed Critical Hangzhou Youwan Technology Co ltd
Priority to CN202010655576.7A priority Critical patent/CN111813677B/zh
Publication of CN111813677A publication Critical patent/CN111813677A/zh
Application granted granted Critical
Publication of CN111813677B publication Critical patent/CN111813677B/zh
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/362Software debugging
    • G06F11/3624Software debugging by performing operations on the source code, e.g. via a compiler
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

本发明涉及一种嵌入式设备上的性能调试方法。其特征在于是通过编译器插桩的方法对函数的入口和出口进行插桩,结合轻量级PMU库达到函数级统计效果,获取***中每个函数的开销并输出采集的结果;再读取之前输出的采集结果文件创建csv文件,解析之前保存的每个函数的记录数据,读取对应的工程的符号表信息、根据函数地址及符号表信息获取函数名称,把每个函数的性能采集数据及函数名称写入csv文件中,并保存,再在csv文件中根据每一项具体的新能数据,分析个函数的开销,找到瓶颈函数。本发明能够迅速定位性能瓶颈函数及***原因,达成性能优化目标。

Description

一种嵌入式设备上的性能调试方法
技术领域
本发明涉及一种嵌入式设备上的性能调试方法。
背景技术
随着物联网技术的发展,各种嵌入式设备越来越多,嵌入式设备上软件也越来越复杂;而目前市面上嵌入式设备所运行的操作***各种各样,freertos、ucos、threadx、nucleus、pikeos、nxp、linux,也有一些基于微内核架构的OS,如L4等。这些***如Linux自带了非常丰富的调试性能调试工具如perf等,但是大部分***并没有提供性能调试手段或者性能调试工具。
目前有些嵌入式设备上甚至只有非常简单的支持多任务的***,完全没有性能调试框架的;但是嵌入式设备又对性能和成本的追求一直在提升,所以需要对嵌入式设备上的运行的程序做不断的优化,从而达到性能最佳。
目前嵌入式设备上的性能调试更多的通过task的角度来分析,即从任务调度的角度来分析;在调度器内部增加一些调试信息,从而确定是哪个任务占用了大部分***时间;在确定任务后再分析任务流程,通过增加trace信息从而找到性能瓶颈的代码及数据。Linux perf是基于采样的,在某种程度上无法做到精确定位;譬如你要去采集cache miss的行为,但perf无法精确的让你知道每个函数发生cache miss的次数。
发明内容
本发明针对现有技术存在的缺点,提供一种嵌入式设备上的性能调试方法,能够迅速定位性能瓶颈函数及***原因,达成性能优化目标。
为此,本发明采取如下的技术方案:一种嵌入式设备上的性能调试方法,其特征在于是通过编译器插桩的方法对函数的入口和出口进行插桩,结合轻量级PMU库达到函数级统计效果,获取***中每个函数的开销并输出采集的结果;再读取之前输出的采集结果文件创建csv文件,解析之前保存的每个函数的记录数据,读取对应的工程的符号表信息、根据函数地址及符号表信息获取函数名称,把每个函数的性能采集数据及函数名称写入csv文件中,并保存,再在csv文件中根据每一项具体的新能数据,分析个函数的开销,找到瓶颈函数。
作为优选,开始采集时,先初始化采集***,创建高性能内存池供后续hash表entity分配使用,初始化PMU,设置相关性能采集event,并enable,设置采集开始flag,***开始采集相关信息,以__cyg_profile_func_enter为每个统计的开始点,为每个函数创建对应的hash表entity,分别记录每个函数的入口和出口对应的性能数据值,并计算相应delta值,同时也记录函数的运行次数等基础数据,并更新到hash表的entity,设置结束采集标志,及设置采集开始的flag=false,发送采集结果获取命令,遍历hash表中的各entity,并根据运行总时间进行快速排序,输出相关结果,保存输出结果到文件中。
作为优选,所述的编译器插桩包括自行增加一个编译器插件,所述的插件在代码编译阶段在函数入口及退出的地方***对应的指令。
作为优选,所述的编译器插桩为直接使用编译器参数-finstrument-functions来对函数的入口和出口进行插桩。
作为优选,所述的函数的开销包括运行时间、运行次数、cache miss rate的性能关键数据。
作为优选,所述的CSV文件为excel文件。
本发明不依赖操作***及软件架构,通过编译器插桩的方式结合轻量级PMU库达到函数级统计效果,从而可以获取***中每个函数的开销,包括运行时间,运行次数,cachemiss rate等性能关键数据,从而迅速定位性能瓶颈函数及***原因,达成性能优化目标。且不需要修改现有任何代码,也不需要操作***修改。对比业界以采样为基础的性能统计,本发明精度更高。根据本发明的对于性能统计,并对结果进行分析后,修改对应软件代码,可以有效提升性能30%以上。
附图说明
图1为本发明的***框架结构示意图。
图2为本发明采集原理流程示意图。
图3为采集具体流程示意图。
图4为性能结果分析示意图。
图5为统计结果示例1。
图6为统计结果示例2。
具体实施方式
下面结合附图对本发明作进一步详细描述。
如图1所示,本发明涉及一种嵌入式设备上的性能调试方法,其通过编译器插桩的方法对函数的入口和出口进行插桩,结合轻量级PMU库达到函数级统计效果,获取***中每个函数的开销并输出采集的结果;再读取之前输出的采集结果文件创建csv文件,解析之前保存的每个函数的记录数据,读取对应的工程的符号表信息、根据函数地址及符号表信息获取函数名称,把每个函数的性能采集数据及函数名称写入csv文件中,并保存,再在csv文件中根据每一项具体的新能数据,分析个函数的开销,找到瓶颈函数。所述的函数的开销包括运行时间、运行次数、cache miss rate等性能关键数据。所述的CSV文件为excel文件。
如图2-图4所示,1.开始采集时,先初始化采集***,创建高性能内存池供后续hash表entity分配使用。2.初始化PMU,设置相关性能采集event,并enable。3.设置采集开始flag,***开始采集相关信息。4.以__cyg_profile_func_enter为每个统计的开始点,为每个函数创建对应的hash表entity。5.分别记录每个函数的入口和出口对应的性能数据值,并计算相应delta值,同时也记录函数的运行次数等基础数据,并更新到hash表的entity。6.设置结束采集标志,及设置采集开始的flag=false。7.发送采集结果获取命令,遍历hash表中的各entity,并根据运行总时间进行快速排序,输出相关结果。8保存输出结果到文件中。
所述的编译器插桩可以通过扩展编译器的plugin等方式,自行增加一个编译器插件,目前LLVM和GCC都支持这种方式。通过自行编写的插件可以在代码编译阶段在函数入口及退出的地方***对应的指令。也可以直接使用编译器参数-finstrument-functions来对函数的入口和出口进行插桩。
如图5-图6所示,根据统计结果生成可供分析的数据表格,从表格中不难看出我们的测试程序时间基本上都花在了test1handler上了,所以只需要对test1handler进行分析即可;进一步分析的话我们可以根据生成的数据可以得出IPC,L1Cache的miss rate,可供进一步的分析。当然一般来讲我们也可以看看函数测执行次数,得出程序中哪些函数是最频繁使用的从而做内联优化。
上述内容仅为本发明的较佳实施举例,并不用于限制本发明。凡在本发明精神和原则之内,所做的任何修改、等同替换、改进等,均应包含在本发明的保护范围之内。

Claims (4)

1.一种嵌入式设备上的性能调试方法,其特征在于是通过编译器插桩的方法对函数的入口和出口进行插桩,结合轻量级PMU库达到函数级统计效果,获取***中每个函数的开销并输出采集的结果;再读取之前输出的采集结果文件创建csv文件,解析之前保存的每个函数的记录数据,读取对应的工程的符号表信息,根据函数地址及符号表信息获取函数名称,把每个函数的性能采集数据及函数名称写入csv文件中,并保存,再在csv文件中根据每一项具体的性能数据,分析各函数的开销,找到瓶颈函数;开始采集时,先初始化采集***,创建高性能内存池供后续hash表entity分配使用,初始化PMU,设置相关性能采集event,并enable,设置采集开始flag,***开始采集相关信息,以__cyg_profile_func_enter为每个统计的开始点,为每个函数创建对应的hash表entity,分别记录每个函数的入口和出口对应的性能数据值,并计算相应delta值,同时也记录函数的运行次数基础数据,并更新到hash表的entity,设置结束采集标志,及设置采集开始的flag=false,发送采集结果获取命令,遍历hash表中的各entity,并根据运行总时间进行快速排序,输出相关结果,保存输出结果到文件中;所述的函数的开销包括运行时间、运行次数、cache miss rate的性能关键数据。
2.根据权利要求1所述的一种嵌入式设备上的性能调试方法,其特征在于所述的编译器插桩包括自行增加一个编译器插件,所述的插件在代码编译阶段在函数入口及退出的地方***对应的指令。
3.根据权利要求1所述的一种嵌入式设备上的性能调试方法,其特征在于所述的编译器插桩为直接使用编译器参数-finstrument-functions来对函数的入口和出口进行插桩。
4.根据权利要求1所述的一种嵌入式设备上的性能调试方法,其特征在于所述的csv文件为excel文件。
CN202010655576.7A 2020-07-09 2020-07-09 一种嵌入式设备上的性能调试方法 Active CN111813677B (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010655576.7A CN111813677B (zh) 2020-07-09 2020-07-09 一种嵌入式设备上的性能调试方法

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010655576.7A CN111813677B (zh) 2020-07-09 2020-07-09 一种嵌入式设备上的性能调试方法

Publications (2)

Publication Number Publication Date
CN111813677A CN111813677A (zh) 2020-10-23
CN111813677B true CN111813677B (zh) 2024-06-25

Family

ID=72843123

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010655576.7A Active CN111813677B (zh) 2020-07-09 2020-07-09 一种嵌入式设备上的性能调试方法

Country Status (1)

Country Link
CN (1) CN111813677B (zh)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112882912B (zh) * 2021-02-01 2022-10-25 华东师范大学 一种应用于并行科学计算程序的函数运行时间测量方法

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101515252A (zh) * 2008-08-26 2009-08-26 南京中兴软创科技股份有限公司 一种量化分析计费***性能的方法
CN102243609A (zh) * 2011-06-15 2011-11-16 惠州运通信息技术有限公司 一种基于嵌入式软件的测试分析方法及***

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5903759A (en) * 1997-06-04 1999-05-11 3 Com Corporation Software performance analysis using hardware analyzer
US20040003375A1 (en) * 2002-06-28 2004-01-01 George Jini S. Method and system for combining dynamic instrumentation and instruction pointer sampling
CN100435111C (zh) * 2005-10-13 2008-11-19 同济大学 异构环境下支持多语言多平台的并行调试及性能分析方法
CN102346710B (zh) * 2011-10-13 2015-04-29 北京航空航天大学 一种基于动态插桩技术的数据包处理时延分析方法
CN109460365B (zh) * 2018-11-16 2019-07-26 苏州好玩友网络科技有限公司 一种***性能测试方法、装置、设备及存储介质

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101515252A (zh) * 2008-08-26 2009-08-26 南京中兴软创科技股份有限公司 一种量化分析计费***性能的方法
CN102243609A (zh) * 2011-06-15 2011-11-16 惠州运通信息技术有限公司 一种基于嵌入式软件的测试分析方法及***

Also Published As

Publication number Publication date
CN111813677A (zh) 2020-10-23

Similar Documents

Publication Publication Date Title
Curtsinger et al. Coz: Finding code that counts with causal profiling
Zhao et al. Dynamic cache contention detection in multi-threaded applications
Chen et al. The Jrpm system for dynamically parallelizing Java programs
Liu et al. Scaanalyzer: A tool to identify memory scalability bottlenecks in parallel programs
Li et al. An efficient data-dependence profiler for sequential and parallel programs
Luo et al. Laser: Light, accurate sharing detection and repair
Chen et al. Atmem: Adaptive data placement in graph applications on heterogeneous memories
Chen et al. Android app energy efficiency: The impact of language, runtime, compiler, and implementation
Koukos et al. Multiversioned decoupled access-execute: The key to energy-efficient compilation of general-purpose programs
EP3144814B1 (en) Method and apparatus for generating a profile of a target program
Yu et al. Fast loop-level data dependence profiling
CN111813677B (zh) 一种嵌入式设备上的性能调试方法
Yu et al. Multi-slicing: a compiler-supported parallel approach to data dependence profiling
Li et al. LDetector: A low overhead race detector for GPU programs
JP2013105256A (ja) 情報処理装置、プロファイル対象決定プログラム及び方法
Dollinger et al. Adaptive runtime selection for GPU
Miucin et al. End-to-end memory behavior profiling with dinamite
Mazaheri et al. Characterizing loop-level communication patterns in shared memory
Olschanowsky et al. Pir: Pmac's idiom recognizer
Kyle et al. Efficiently parallelizing instruction set simulation of embedded multi-core processors using region-based just-in-time dynamic binary translation
Laurenzano et al. A static binary instrumentation threading model for fast memory trace collection
Gnedt Fast Profiling in the HotSpot Java VM with Incremental Stack Tracing and Partial Safepoints
Rane et al. Performance optimization of data structures using memory access characterization
Aulagnon et al. Runtime function instrumentation with EZTrace
Wang et al. Lightweight hardware transactional memory profiling

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant