Archive

Archive for the ‘工具介绍’ Category

给你的Linux系统上点stress

January 9th, 2012 No comments

原创文章,转载请注明: 转载自Erlang非业余研究

本文链接地址: 给你的Linux系统上点stress

《debug hacks》 这本书介绍了非常多的调试手段和工具, 其中提到了stress这个简单的压力测试工具,在我们的日常工作中很有用。利用它可以给我们的系统施加CPU,内存,IO和磁盘的压力,在模拟极端场景给应用系统造成的压力方面很有帮助。

主页见这里:http://weather.ou.edu/~apw/projects/stress/
这里还有一篇介绍如何使用的博客。

stress is a deliberately simple workload generator for POSIX systems. It imposes a configurable amount of CPU, memory, I/O, and disk stress on the system. It is written in C, and is free software licensed under the GPLv2.

这个stress实现非常的简单,所有的功能在一个.c文件里面实现, 系统运行的时候会fork多个子进程,分别进行CPU,内存,IO方面的折磨。
Read more…

Post Footer automatically generated by wp-posturl plugin for wordpress.

Categories: Linux, 工具介绍 Tags:

fio配合cgroup测试存储设备IOPS分配

December 28th, 2011 No comments

原创文章,转载请注明: 转载自Erlang非业余研究

本文链接地址: fio配合cgroup测试存储设备IOPS分配

随着包括存储设备在内服务器的能力越来越高,特别是用上了PCIe存储卡后,IOPS能力通常有10几万,马上过剩。在这种情况下,一台服务器可以干很多事情,在上面跑很多服务。那么如何保证系统的服务质量是个很重要的事情了。

我们在下来的的项目中倾向于用cgroup来做资源的隔离和限制,原因是cgroup的开销很小,而且很易用。cgroup 可以参考这里

我们特别关心cgroup的blkio子模块,他有2种限制模式:
1. throttle,限制每个进程能使用的IOPS或者吞吐量。
2. weight,现在每个进程能使用的IOPS的能力的比例,必须通过CFQ调度器来实现。
文档和具体的参数可以看上面提到的cgroup文档。

Read more…

Post Footer automatically generated by wp-posturl plugin for wordpress.

Categories: Linux, 工具介绍, 调优 Tags: ,

slabtop简单的用途

December 15th, 2011 5 comments

原创文章,转载请注明: 转载自Erlang非业余研究

本文链接地址: slabtop简单的用途

我们知道内核的模块在分配资源的时候,为了提高效率和资源的利用率,都是透过slab来分配的。我们通过slab的信息,再配合源码能粗粗了解系统的运行情况,比如说什么资源有没有不正常的多,或者什么资源有没有泄漏。

linux系统透过/proc/slabinfo来向用户暴露slab的使用情况的,我们来看下:

$ head /proc/slabinfo
slabinfo - version: 2.0
# name            <active_objs> <num_objs> <objsize> <objperslab> <pagesperslab> : tunables <batchcount> <limit> <sharedfactor> : slabdata <active_slabs> <num_slabs> <sharedavail>
msi_cache              2      2   3840    1    1 : tunables   24   12    8 : slabdata      2      2      0
ip_fib_alias          11    226     16  226    1 : tunables  120   60    8 : slabdata      1      1      0
ip_fib_hash           11    119     32  119    1 : tunables  120   60    8 : slabdata      1      1      0
dm_mirror            100    105   1052    7    2 : tunables   24   12    8 : slabdata     15     15      0
dm_mpath               0      0   1052    7    2 : tunables   24   12    8 : slabdata      0      0      0
dm_tio                 0      0     16  226    1 : tunables  120   60    8 : slabdata      0      0      0
dm_io                  0      0     20  185    1 : tunables  120   60    8 : slabdata      0      0      0
dm-bvec-(256)          0      0   3072    2    2 : tunables   24   12    8 : slabdata      0      0      0
...

其实还有更好的查看工具:slabtop很直观的可以看到slab使用情况和汇总,上图:

很清晰的为性能调优和trouble shoot提供一个参考面!

祝玩得开心!

Post Footer automatically generated by wp-posturl plugin for wordpress.

Categories: Linux, 工具介绍, 调优 Tags:

调研内核调用栈方便的工具 kmalloc-top

December 14th, 2011 No comments

原创文章,转载请注明: 转载自Erlang非业余研究

本文链接地址: 调研内核调用栈方便的工具 kmalloc-top

我们在研究内核的时候,看了内核代码后,就想着某个函数被谁谁调用。 调用路径有很多条,有热门的,有偏门的,但从代码不大容易看出。 如果我们能和gdb那样在函数上设个断点,看下内核函数的调用栈就清楚了。 但是如何统计热门路线呢?用systemtap就可以,参看这里这里

但是用systemtap写统计的时候,用到统计功能的话,如果你的采样点非常多,超过systemtap规定的上线,systemtap会选择罢工,直接推出,很不爽。

kmalloc-top就是为了解决这个问题写的一个perl脚本,原本用来调查内核中kmalloc的使用情况的,在一个繁忙的内核中,kmallo每秒会被调用成千上万次,明显会超过处理的上限。 所以kmalloc-top的方法是stap部分只负责收集堆栈信息,收集一个就写到标准输出一个,然后由perl脚本来进一步分析统计。

脚本位于:/usr/local/share/doc/systemtap/examples/memory/kmalloc-top
Read more…

Post Footer automatically generated by wp-posturl plugin for wordpress.

Categories: Linux, 工具介绍 Tags: ,

Flashcache新添加驱逐空闲脏页参数

December 10th, 2011 No comments

原创文章,转载请注明: 转载自Erlang非业余研究

本文链接地址: Flashcache新添加驱逐空闲脏页参数

我在之前的博文提过Flashcache的cache是以set为单位管理的,每个set默认2M。 当单个set里面的脏页数量超过dirty_thresh_pct的时候,就会启动背景工作队列来把超过设置的脏页回写到后备磁盘去。 这里有别的同学对flashcache设计文档的翻译.

参看dirty_thresh_pct的文档解释:

dev.flashcache..dirty_thresh_pct = 20
Flashcache will attempt to keep the dirty blocks in each set
under this %. A lower dirty threshold increases disk writes,
and reduces block overwrites, but increases the blocks
available for read caching.

Flashcache之所以这样做的目的是当它在处理用户IO请求需要cache块的时候,保证马上可以拿的出来。因为读写的时候,如果需要的cache块不能满足的话,flashcache选择简单的绕过cache机制,直接走uncache io, 同时启动页面回收,一下子收回超过设置部分的页面,对性能有很大的损失。
特别是顺序写的时候,写一圈,再回绕在写的场合,性能特别差,就是这个原因。

那么如何保持一定量的可用cache块就很重要。通常cache数据都有冷热点,而且和时间很大关系。flashcache对冷热的判断是透过LRU类似的算法来判断的,这个是基于使用频度的维度。但是缺乏时间维度的判断。

新版本的flashcache引入了fallow_delay参数来解决这个问题,如果一个脏页超过fallow_delay秒,默认15分钟,都没有重新被访问到,那么数据就会被回写。 回写后,作为候选页面可以被新的cache重新利用。
Read more…

Post Footer automatically generated by wp-posturl plugin for wordpress.

vmtouch-系统pagecache查看和操纵器

December 8th, 2011 4 comments

原创文章,转载请注明: 转载自Erlang非业余研究

本文链接地址: vmtouch-系统pagecache查看和操纵器

今天看到dbanote这篇博文介绍的技术清单,里面列到了很多有意思的技术。其中提到了一个小工具vmtouch,主页见这里

vmtouch – the Virtual Memory Toucher
Portable file system cache diagnostics and control
vmtouch is a tool for learning about and controlling the file system cache of unix and unix-like systems. It is BSD licensed so you can basically do whatever you want with it.

我之前写过不少之类的博文,但是基本都是用systemtap,工具也零碎,现在vmtouch比较系统的把功能整合在一起,源码写的虽然简单,但是用到了还是挺管用的。

顺手贴了下vmtouch的使用:
Read more…

Post Footer automatically generated by wp-posturl plugin for wordpress.

Categories: Linux, 工具介绍 Tags: ,

关于ramdisk

December 5th, 2011 No comments

原创文章,转载请注明: 转载自Erlang非业余研究

本文链接地址: 关于ramdisk

ramdisk是Linux内核带的一个以内存为后备的虚拟设备,以块设备方式提供。 具体功能参见Documentation/ramdisk.txt,代码参见drivers/block/brd.c.

内核在启动的时候会预设几个ramdisk, 初始大小通常为128K的块设备,方便有需要的用户。

$ uname -r
2.6.32-131.0.15.el6.x86_64
$ ls /dev/ram0 -al
brw-rw---- 1 root disk 1, 0 2011-12-02 11:41 /dev/ram0
$ sudo blockdev --getsize /dev/ram0
131072

在实践中ramdisk有如下几个用途:
1. ramdisk的代码写的非常简洁,很容易让你明白块设备如何编写。
Read more…

Post Footer automatically generated by wp-posturl plugin for wordpress.

Categories: Linux, 工具介绍 Tags: