`
hideto
  • 浏览: 2682851 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

HPM Note3, Benchmarking and Profiling

阅读更多
Note3, Finding Bottlenecks: Benchmarking and Profiling

Benchmarking and profiling are two essential practices for finding bottlenecks
A benchmark measures your system's performance. This can help determine a system's capacity, show you which changes matter and which don't, or show how your application performs with different data
Profiling helps you find where your application spends the most time or consumes the most resources
Benchmarking answers the question "How well does this perform?" and profiling answers the question "Why does it perform the way it does?"

Why Benchmark?
Benchmarks can help you do:
Measure how your application currently performs
Validate your system's scalability
Plan for growth
Test your appplication's ability to tolerate a changing environment
Test different hardware, software, and operating system ocnfigurations

Benchmarking Strategies
There are two primary benchmarking strategies: you can benchmark the appplication as a whole, or isolation MySQL
These two strategies are known as full-stack and single-component benchmarking respectively
What to measure:
Transactions per time unit, Response time or latency, Scalability, Concurrency

Benchmarking Tactics
The first step in planning a benchmark is to identify the problem and the goal
Try to record as much additional information as you can during the benchmarks, such as CPU usage, disk I/O, and network traffic statistics, counters from SHOW GLOBAL STATUS
The best way to get accurate results is to design your benchmark to answer the question you want to answer
It's usually a good idea to automate the benchmark runs

Benchmarking Tools
Full-Stack Tools:
ab
ab is a well-known Apache HTTP server benchmarking tool, it shows how many requests per second your HTTP server is capable of serving

http_load
Similar tool in concept to ab, it's also designed to load a web server, but more flexible

JMeter
A Java application that can load another application and measure its performance, much more complex

Single-Component Tools:
mysqlslap
mysqlslap simulates load on the server and reports timing information

sysbench
sysbench is a multithreaded system benchmarking tool
You can measure the performance of file I/O, the OS scheduler, memory allocation and transfer speed, POSIX threds, and the database server itself
sysben supports scription in the Lua language, which makes it very flexible for testing a variety of scenarios

Database Test Suite
a test kit for running benchmarks similar to some industry-standard benchmarks, such as those published by TPC

MySQL Benchmark Suite
MySQL's own benchmark suite, single-threaded and measure how quickly the server executes queries

Super Smack
a benchmarking, stress-testing, and load-generating tool for MySQL and PostgreSQL
It's a complex, powerful tool that lets you simulate multiple users, load test data into the database, and populate tables with randomly generated data

Benchmarking Examples
$ http_load -parallel 1 -seconds 10 urls.txt
$ http_load -paraleel 5 -seconds 10 urls.txt
$ http_load -rate 5 -seconds 10 urls.txt
$ http_load -rate 20 -seconds 10 urls.txt

$ sysbench --test=cpu --cpu-max-prime=20000 run

$ sysbench --test=fileio --file-total-size=150G prepare
$ sysbench --test=fileio --file-total-size=150G --file-test-mode=rndrw --init-rnd=on --max-time=300 --max-requests=0 run
$ sysbench --test=fileio --file-total-size=150G cleanup

$ sysbench --test=oltp --oltp-table-size=1000000 --mysql-db=test --mysql-user=root prepare
$ sysbench --test=oltp --oltp-table-size=1000000 --mysql-db=test --mysql-user=root --max-time=60 --oltp-read-only=on --max-requests=0 --num-threads=8 run

sql-bench$ ./run-all-tests --server=mysql --user=root --log --fast
sql-bench$ ./test-insert


Profiling
Database access if often the bottleneck in application
Bottlenecks can also be caused by any of the following:
External resources, such as calls to web services or search engines
Operations that require processing large amounts of data in the application, such as parsing big XML files
Expensive operations in tight loops, such as abusing regular expressiosn
Badly optimized algorithms, such as naive search algorithms to find items in lists

Application profiling can help you find the bottlenecks, and it's an important step in monitoring and improving overall performance

We recommend that you include profiling code in every new project you start
Your profiling code should gather and log at least the following:
Total execution time, or "wall-clock time"(in web applications, this is the total page render time)
Each query executed, and its execution time
Each connection opened to the MySQL server
Every call to an external resource, such as web services, memcached, and externally invoked scripts
Potentially expensive function calls, such as XML parsing
User and system CPU time

MySQL has two kinds of query logs: the general log and the slow log
The general log writes out every query as the server receives it, even some events such as connecting and disconnecting and queries may not even be executed due to errors
log = <file_name>

The slow log contains only queries that have executed
In particlular, slow log logs queries that take more than a specified amount of time to execute
log-slow-queries = <file_name>
long_query_time = 2
log-queries-not-using-indexex
log-slow-admin-statements


Log analysis tools:
mysqldumpslow
mysql_slow_log_filter
mysql_slow_log_parser
mysqlsla
SHOW STATUS/SHOW PROFILE

Operating System Profiling
netstat
vmstat
iostat
mpstat
strace
OProfile
pgrof
Intel VTune, Sun Performace Analyzer, DTrace
分享到:
评论
1 楼 hideto 2009-07-02  
FW也是在Rails程序里有Profiling相关的代码的,每天发一个TOP 20 slow urls和TOP 20 slow queries的report出来。其实这个可以做成一个通用的插件的,不知道有没有现成的

相关推荐

    先楫半导体 HPM6700/6400 系列高性能微控制器用户手册

    HPM6700/6400 系列微控制器是基于 RISC-V 内核的 32 位高性能微控制器,适用于上海先楫半导体科技有限公司以下型号产品:HPM6750IVM1、HPM6750IAN1、HPM6730IVM1、HPM6730IAN1、HPM6450IVM1、HPM6450IAN1、HPM6430...

    HPM1005驱动程序

    3. pnp:即“Plug and Play”(即插即用),意味着该驱动支持Windows操作系统中的自动识别和配置设备功能。 4. win2kxp:表示该驱动程序兼容Windows 2000和Windows XP操作系统,说明这是一个较老版本的驱动,可能不...

    上海先楫HPM6750采集OV5640摄像头显示在屏幕【支持HPM6750和HPM6450】

    上海先楫HPM6750是一款高性能的嵌入式微处理器,专为处理复杂的多媒体应用而设计。这款芯片在物联网(IoT)、智能硬件、工业自动化等领域有着广泛的应用。HPM6450是其系列中的另一款处理器,虽然可能在性能上有所区别...

    PICMG_HPM_1R1_0.pdf

    《HPM.1硬件平台管理:IPM控制器固件升级规范》 HPM.1(Hardware Platform Management)是PICMG(PCI工业计算机制造商集团)发布的一项标准,旨在规范服务器和其他计算平台的硬件平台管理,特别是关于IPM...

    上海先楫HPM6750驱动EMMC和SD卡【支持HPM6750和HPM6450】

    上海先楫HPM6750驱动EMMC和SD卡的开发是嵌入式系统设计中的关键环节,尤其对于基于HPM6750和HPM6450处理器的设备来说,高效的存储器管理是确保系统性能和稳定性的基础。这个代码工程提供了一个完整的解决方案,使...

    HPM1210.INF

    HPM1210.INF

    hpm1210sd.rar

    【标题】"hpm1210sd.rar"是一个压缩文件,通常用于在互联网上分享或存储多个相关文件。从这个名字来看,它可能是某个特定硬件设备、软件程序或者相关项目的一部分,具体而言,"HPM1210SD"可能代表一个型号、版本号...

    TDC 3000 系统 HPM组态手册

    《TDC 3000系统HPM组态手册》是针对HONEYWELL公司旗下的TDC 3000控制系统的一份详细指南,主要涵盖了该系统的模块配置和设定,尤其适用于石化行业的分布式控制系统(DCS)应用。在这个高度集成且复杂的自动化系统中...

    HPM1210SU.ent

    HPM1210SU.ent HPM1210SU.ent HPM1210SU.ent

    HPM1210SM.exe

    HPM1210SM.exe

    HPM1210SU.VER

    HPM1210SU.VER

    HPM.rar_ZIY_hpm

    标题中的"HPM.rar_ZIY_hpm"表明这是一个关于HPM(可能是Hercules Performance Monitor)的压缩文件,由用户ZIY创建或整理,主要用于HercWS(可能是指Hercules Web Services)。"ziy hpm"的标签进一步确认了这个文件...

    hpm1005win7驱动

    描述中的“win7可以使用”确认了HP LaserJet M1005打印机在Windows 7系统上是支持的,并且提到了“hpm10005win7的驱动”,这可能是描述中的一个小错误,应该是指“hpm1005win7”的驱动,即对应的是HP LaserJet M1005...

    HPM1210PP.dll

    HPM1210PP.dll

    HPM1210GC.DLL

    HPM1210GC.DLL

    HPM1210FPSD.DLL

    HPM1210FPSD.DLL

    上海先楫HPM6750驱动LCD屏上显示内容【支持HPM6750和HPM6450】

    上海先楫HPM6750驱动LCD屏上显示内容的工程是专为HPM6750和HPM6450处理器设计的。这个项目的核心在于如何有效地利用这两款处理器的特性来控制和显示LCD屏幕上的信息。在嵌入式系统中,这种驱动程序的开发对于实现人...

    HPM1005驱动

    适用于XP32位操作系统的HPm1005打印机驱动

    上海先楫HPM6750实现CAN和CAN-FD通信【支持HPM6750和HPM6450】

    在本文中,我们将深入探讨如何使用上海先楫的HPM6750和HPM6450处理器实现CAN(Controller Area Network)和CAN-FD(Controller Area Network with Flexible Data-rate)通信。这两种通信协议在嵌入式系统,尤其是...

    OCP_2014_firware_update_HPM.1.pdf

    HPM.1 Firmware Update Open Compute Summit - Compute Summit HPM.1 Firmware Update Engineering Workshop HPM.1 File Format File is not sent as a single image Each action is sent by itself to IPM ...

Global site tag (gtag.js) - Google Analytics