LISA介绍及其使用方法
LISA是ARM公司开发的一款开源工具。在内核开发过程中,苦于无法针对修改内容进行一些量化或者可视化结果的测量,而无感。LISA对于模型调优,回归测试都有较强的支持。
什么是LISA?
LISA是Linux Interactive System Analysis的缩写,从字面意思可以看出是一个分析工具,具有交互性特点,这有赖于ipython脚本。
LISA是一个Linux环境下用于回归测试和对于各种workload进行交互测试的工具集。目前LISA主要专注于scheduler、power management和thermal框架的分析。但不仅于此,LISA提供一个框架且可以轻松扩展到其他用途。
LISA提供一些列API用于测试条例编写和回归测试条例开发。一系列针对内核核心功能的回归测试条例已经提供。另外,LISA使用卓越的IPython Notebook框架和一些示例用于进行实验。
LISA用来干什么?
- 有助于学习已有的功能
- 有助于开发新的代码
- 有助于发现问题,并且找到原因
- 有助于分享可复制的测试:
- 足够的弹性保证在不同待测设备上重复同样的实验
- 简化预定义workload的生成和执行
- 定义一系列方法来评估内核行为
- 更简单的获取数据文件来生成统计信息和报表
LISA框架结构
待续:devlib/workload/trappy/bart/target什么功能?扩展?
TRAPpy
TRAPpy,即Trace Analysis and Plotting in Python,是一个用于分析数据的可视化工具。它分析类ftrace日志文件,然后基于分析数据创建图表和数据分析。
TRAPpy需要一些其他工具的支持才能正常工作,比如trace-cmd、kernelshark。trace-cmd用于将trace.dat转换成trace.txt文件。
TRAPpy安装
Install additional tools required for some tests and functionalities
sudo apt install trace-cmd kernelshark
安装pip等工具:
sudo apt install python-pip python-dev
安装依赖库文件:
sudo apt install libfreetype6-dev libpng12-dev python-nose
sudo pip install numpy matplotlib pandas ipython[all]
安装TRAPpy:
sudo pip install --upgrade trappy
TRAPpy使用
启动一个ipython notebook服务:
ipython notebook
会弹出一个浏览器,可以在里面创建,修改,执行脚本。
API文档:https://pythonhosted.org/TRAPpy/
BART
BART,即Behavioural Analysis and Regression Toolkit,基于TRAPpy,分析kernel输出的ftrace来诊断当前的行为是否符合预期。
安装BART
Install additional tools required for some tests and functionalities
$ sudo apt install trace-cmd kernelshark
Install the Python package manager
$ sudo apt install python-pip python-dev
Install required python packages
$ sudo apt install libfreetype6-dev libpng12-dev python-nose
$ sudo pip install numpy matplotlib pandas ipython[all]
$ sudo pip install --upgrade trappy
ipython[all]
will install IPython Notebook, a web based interactive python programming interface. It is required if you plan to use interactive plotting in BART.
Install BART
$ sudo pip install --upgrade bart-py
BART的用途
BART具有广泛的用途,主要用于帮助开发者进行一些难以测试功能的自动化测试。
内核开发者:确保代码的正确性
性能优化工程师:图形化/诊断不同内核版本之间的性能表现。
质量管理、版本工程师:验证不同模块/patch集成特性。
API文档:https://pythonhosted.org/bart-py
devlib
代码路径:https://github.com/ARM-software/devlib
devlib提供一个基于Linux操作系统设备,用于交互和获取测量结果的接口。
wlgen/workload
用于生成各种负荷,目前主要支持rt-app。
LISA使用
准备工作
下载LISA:git clone https://github.com/ARM-software/lisa.git
运行LISA:source init_env,如下:
更新LISA依赖模块
lisa-update
使用LISA进行测试
lisa-test tests/eas/acceptance.py
使用LISA分析
执行lisa-ipython后,会打开浏览器。在浏览器中可以通过创建IPython脚本进行LISA相关测试。
LISA代码分析
下面是LISA根目录的二级树,LISA具有明显的模块化区分,基于已有的框架可以轻松编写测试用例tests,编写自己想要的测试结果ipynb。
可以看出libs/utils提供LISA基础框架,
libs/devlib支持和待测设备之间交互连接,
测试用例在tests中,
libs/wlgen产生特定workload,
测试结果在results中,
使用ipynb下各种基本进行分析,
ipynb需要的python库在libs中。
├── assets |
下面重点分析libs/utils、libs/wlgen、libs/devlib、libs/trappy、libs/bart,然后如何写自己的测试用例,并作分析。
libs/utils
class LisaTest是LISA测试用例的基类,调用class TestEnv配置测试环境,调用class Executor生成Executor。
@classmethod cls.logger.info('Setup tests execution engine...') experiments_conf = cls._getExperimentsConf(test_env) # Alias executor objects to make less verbose tests code # Execute pre-experiments code defined by the test cls.logger.info('Experiments execution...') # Execute post-experiments code defined by the test |
class TestEnv用于配置LISA执行环境,基于target_conf配置待测设备,基于test_conf配置需要针对测试进行设置,还进行工作目录、测试工具等设置。
def __init__(self, target_conf=None, test_conf=None, wipe=True, super(TestEnv, self).__init__() … # Keep track of android support # Setup logging # Compute base installation path # Setup target configuration # Setup test configuration # Setup target working directory # Initialize binary tools to deploy # Initialize ftrace events # Initialize features self._init() # Initialize FTrace events collection # Initialize RT-App calibration values # Initialize local results folder res_lnk = os.path.join(basepath, LATEST_LINK) # Initialize energy probe instrument |
class Executor是实际生成workload的部分,worload的具体情况在experiments_conf中配置。
def __init__(self, test_env, experiments_conf): A tests executor is a module which support the execution of a The executor module can be configured to run a set of workloads (wloads) All the results generated by each experiment will be collected a result After the workloads have been run, the Executor object's `experiments` # Initialize globals # Setup logging # Setup test configuration 解析experiments_conf,这些参数都会传递给wlgen执行。 self._print_section('Experiments configuration') 打印此实验配置 … |
Executor.run根据Executor.__init__解析的配置,以workload为单位开始执行。
def run(self): self.experiments = [] # Run all the configured experiments # WORKLOAD: execution self._print_section('Experiments execution completed') |
Executor._wload_run执行单个workload:
def _wload_run(self, exp_idx, experiment): self._print_title('Experiment {}/{}, [{}:{}] {}/{}'\ # Setup local results folder # Freeze all userspace tasks that we don't need for running tests # FTRACE: start (if a configuration has been provided) # ENERGY: start sampling 抓取Power Meter数据 # WORKLOAD: Run the configured workload 下面是收集Power Meter和ftrace数据。 # ENERGY: collect measurements # FTRACE: stop and collect measurements trace_file = experiment.out_dir + '/trace.dat' stats_file = experiment.out_dir + '/trace_stat.json' # Unfreeze the tasks we froze self._print_footer() |
为了尽量降低测试的干扰,引入了freeze_userspace这个flag,这是基于CGroup的freezer子系统实现的。将必须要保留的进程之外的进程,全部冻结。
critical_tasks = { |
在Executor._wload_conf根据wordload配置,调用wlgen生成workload。
def _wload_conf(self, wl_idx, wlspec): # CPUS: setup execution on CPUs if required by configuration # CGroup: setup CGroups if requried by configuration if wlspec['type'] == 'rt-app': raise ValueError('unsupported "type" value for [{}] ' |
platforms下存放的是不同类型主板的配置文件。
analysis目录下存放的是针对不同关注点(比如,cpus、eas、frequency、idle)等解析trace.txt的脚本,经过这些脚本处理。ipython Notebook可以生成可视化图表。
class CpusAnalysis
如何扩展?
需要编写自己设备的配置文件target.conf:
{ /* Board */ /* Target Android device ID */ /* Login username (has to be sudo enabled) */ … /* Devlib modules to enable/disbale for all the experiments */ … /* List of test environment features to enable */ |
在utils/analysis下,基于class AnalysisModule扩展自己的分析脚本,生成图表。
libs/wlgen
class Workload作为各种workload的基类,class RTA是class Workload子类。
class Workload的__init__最主要的是进行参数的初始化,使用target.config配置。
run是class Workload的核心,该方法是负荷的执行主体。如果需要抓取ftrace,也会在这里收集。
def run(self, self.cgroup = cgroup # Compose the actual execution command starting from the base command if not _command: # Prepend eventually required taskset command if self.cgroup and hasattr(self.target, 'cgroups'): # Start FTrace (if required) # Wait `start_pause` seconds before running the workload # Start task in background if required # Start task in foreground # Wait `end_pause` seconds before stopping ftrace # Stop FTrace (if required) if not background: return ftrace_dat |
在了解了基类Workload之后,稍微了解一下class RTA。
RTA根据需要增加了calibrate,用于在执行rtapp workload之前,校准cpu的性能。
另外扩展了四种任务类型,class Ramp、class Step、class Pulse和class Periodic。
如何扩展?
workload的扩展都是基于class Workload进行。如果需要创建自己的workload,就需要参照rta.py,写一个自己的子类;class LocalLinuxTarget作为class LinuxTarget的子类,用于测试本地host设备。
libs/devlib
target.py中定义了基类class Target,以及两种类型的子类class LinuxTarget和class AndroidTarget,针对ssh连接设备和adb连接设备。
class Workload的三个子类,分别对应三种不同类型的连接class AdbConnection、class SshConnection和class LocalConnection。
class FtraceController进行ftrace抓取前buffer大小、filter等的设置,导出ftrace,进行trace.dat到trace.txt的转变,以及抓取结束后的清理工作。
instrument的__init__.py中定义了基类class Instrument,用于扩展不同类型的测量仪器,一般对应的是物理上存在的设备。
class DaqInstrument、class EnergyProbeInstrument和class HwmonInstrument分别对应DAQ、Energy Probe和hwmon三种设备。
class Module基类用于针对不同模块进行配置,有的是配置某一模块的内核sysfs节点,有的是使用命令执行操作。
比如class BigLittleModule,online/offline不同cluster的CPU,或者获取CPU的各种信息。
class CpufreqModule显示/设置CPU的governor、最高频率、当前频率等等信息。
bin存放devlib用到的可执行文件,比如busybox、trace-cmd等。
如何扩展?
所以综合下来,在devlib中可能根据class Workload需要扩展不同类型的连接。
如果有新的测试仪器,需要扩展class Instrument。
有时候为了方便对摸快操作,可以基于class Module进行扩展。
libs/trappy
从TRAPpy的缩写即可知道,一是解析trace,二是对解析结果进行可视化显示。
在trappy/trappy下有很多python脚本,里面注册了很多ftrace的解析器,register_ftrace_parser和register_dynamic_ftrace。
libs/bart
在进行了这些分析之后,可以看出test、experiment、workload之间的关系。
一个test可以对应一个或多个experiment;一个experiment可以对应一个或多个workload。
test对应tests目录中的脚本,experiment对应Executor,workload对应wlgen。
编写测试用例
编写分析脚本
参考资料
- LISA Wiki:https://github.com/ARM-software/lisa/wiki
- LISA Git:https://github.com/ARM-software/lisa
LISA介绍及其使用方法的更多相关文章
- block(代码块)的介绍以及使用方法和变量之间的关系
http://blog.csdn.net/menxu_work/article/details/8762848 block(代码块)的介绍以及使用方法和变量之间的关系 block(代码块)的介绍以及使 ...
- 【转】【Android UI设计与开发】第07期:底部菜单栏(二)Fragment的详细介绍和使用方法
原始地址:http://blog.csdn.net/yangyu20121224/article/category/1431917/1 由于TabActivity在Android4.0以后已经被完全弃 ...
- react-native热更新之CodePush详细介绍及使用方法
react-native热更新之CodePush详细介绍及使用方法 2018年03月04日 17:03:21 clf_programing 阅读数:7979 标签: react native热更新co ...
- DELPHI中枚举类型数据的介绍和使用方法
在看delphi程序的时候看到aa=(a,b,c,d);这样的东西,还以为是数组,同事说是函数,呵呵,当然这两个都不屑一击,原来这样式子是在声明并付值一个枚举类型的数据.下边写下来DELPHI中枚举类 ...
- JQuery onload、ready概念介绍及使用方法
页面加载完成有两种事件,一是ready,表示文档结构已经加载完成,onload,ready概念容易混淆,下面为大家详细介绍下 页面加载完成有两种事件,一是ready,表示文档结构已经加载完成(不包 ...
- CSRF简单介绍及利用方法-跨站请求伪造
0x00 简要介绍 CSRF(Cross-site request forgery)跨站请求伪造,由于目标站无token/referer限制,导致攻击者可以用户的身份完成操作达到各种目的.根据HTTP ...
- C++ stringstream介绍,使用方法与例子
From: http://www.usidcbbs.com/read-htm-tid-1898.html C++引入了ostringstream.istringstream.stringstream这 ...
- ASP中文件上传组件ASPUpload介绍和使用方法
[导读]要实现该功能,就要利用一些特制的文件上传组件.文件上传组件网页非常多,这里介绍国际上非常有名的ASPUpload组件 1 下载和安装ASPUpload 要实现该功能,就要利用一些特制的文件上 ...
- hexo工具介绍及使用方法
Hexo is a fast, simple & powerful blog framework 安装方法:npm install hexo-cli -g; require:node.js g ...
随机推荐
- Basic Tutorials of Redis(2) - String
This post is mainly about how to use the commands to handle the Strings of Redis.And I will show you ...
- ASP.NET + EF + SQL Server搭建个人博客系统新手系列(一):界面展示
第一次写博客,可能有些地方描述的不准确,还请大家将就.本人大四学生,学了半年C#,半年.net,但是很遗憾,学完之后只会写个hello word.老师教的过程中总是会套用一些模板,特别是后台,完全封装 ...
- Navisworks 2014 Api 简单的使用
初次接触Navisworks Api .NET 的二次开发.主要是研究了一下.关于NavisWorks 结构树的加载. void LoadModel() { //清空当前的结构树信息 treeVie ...
- Web Service概念梳理
计算机技术难理解的很多,Web Service 对我来说就是一个很难理解的概念:为了弄清它到底是什么,我花费了两周的时间,总算有了一些收获,参考了不少网上的资料,但有些概念说法不一.我以w3c和 一些 ...
- 【译】Asp.net mvc 使用ITextSharp PDF to HTML (解决img标签问题)
前言:因项目需求,需要将HTML代码转成PDF.大致上已经实现了,可以是发现使用ITextSharp(我现在的版本是5.5.9)的时候,img标签中的src只能跟绝对路径. 在百度上找了一个上午,有一 ...
- C#开发微信门户及应用(12)-使用语音处理
我们知道,微信最开始就是做语音聊天而使得其更加流行的,因此语音的识别处理自然也就成为微信交流的一个重要途径,微信的开发接口,也提供了对语音的消息请求处理.本文主要介绍如何利用语音的识别,对C#开发的微 ...
- C#开发微信门户及应用(5)--用户分组信息管理
在上个月的对C#开发微信门户及应用做了介绍,写过了几篇的随笔进行分享,由于时间关系,间隔了一段时间没有继续写这个系列的博客了,并不是对这个方面停止了研究,而是继续深入探索这方面的技术,为了更好的应用起 ...
- 笔记:解决VS2015 不能加载.edmx 的解决方案
1. 首先你要安装 VS2015镜像中的packages->EFTools文件(最后拷贝出来,因为发现直接运行其下的EFTools.msi文件安装会有问题),然后安装里面的EFTools.msi ...
- session的使用方法详解
session的使用方法详解 Session是什么呢?简单来说就是服务器给客户端的一个编号.当一台WWW服务器运行时,可能有若干个用户浏览正在运正在这台服务器上的网站.当每个用户首次与这台WWW服务器 ...
- spring源码:IOC(li)
一.BeanDefinition BeanDefinition是配置文件<bean>元素标签在容器中内部表示形式.创建最终的BeanDefinition主要包括两个步骤: 1)利用Bean ...