1. 程式人生 > 實用技巧 >stressapptest使用介紹【轉】

stressapptest使用介紹【轉】

轉自:https://blog.csdn.net/vichie2008/article/details/50457566

stressapptest 其是:Stressful Application Test (stressapptest) 的簡稱

Stressful Application Test試圖讓來自處理器和I/O到記憶體的資料儘量隨機化,以創造出模擬現實的環境來測試現在的硬體裝置是否穩定,Google就在使用它,現在是Apache 2.0許可,這裡有介紹安裝嚮導指南(http://code.google.com/p/stressapptest/wiki/InstallationGuide)。不過連線可能被牆,要用代理上。

其大概如下:

stressapptest may be used for various purposes:

  • Stress test: as described here. 壓力測試
  • Hardware qualification and debugging. 硬體檢查和除錯
  • Memory interface test: see theTheorybehind this. 記憶體介面測試
  • Disk testing. 磁碟測試
據谷歌的介紹,這個軟體會生產執行緒來拷貝和直接對磁碟進行讀取和寫入。目標則是儘可能地載入系統記憶體,以便更加有效地進行測試。該軟體更多的時候測試的是記憶體控制器和匯流排介面,而不是儲存單元的功能。谷歌稱,與其他記憶體診斷程式的比較,五分之一的記憶體模組相關的系統誤差只能通過stressapptest發現。

Background

Many hardware issues reproduce infrequently, or only under corner cases. The theory being used here is that by maximizing bus and memory traffic, the number of transactions is increased, and therefore the probability of failing a transaction is increased. 這個測試會最大化匯流排和記憶體的交換量,從而交換失敗的概率也會增加。

Overview

stressapptest is a userspace test, primarily composed of threads doing memory copies and direct IO disk read/write. It allocates a large block of memory (typically 85% of the total memory on the machine), and each thread will choose randomized blocks of memory to copy, or to write to disk. Typically there are two threads per processor, and two threads for each disk. Result checking is done as the test proceeds by CRCing the data as it is copied. 該軟體採用多執行緒對記憶體進行拷貝和磁碟介面讀寫,佔用了85%的記憶體塊,而且每個執行緒都是隨機進行的讀寫操作,一般每個處理器2個執行緒,磁碟也是;

Downloading it

stressapptest can be download athttp://code.google.com/p/stressapptest/downloads

Detailed Design

The code is structured fairly simply: 程式碼結構簡單

  • A large amount of memory is allocated in a single block (default is 85% of physical memory size). 每個資料塊都佔用到了大量記憶體資源
  • Memory is divided into chunks, each filled with a potentially stressful data pattern. 記憶體被分成了許多塊,每塊都覆蓋了對應大量的資料;
  • Worker threads are spawned, which draw pages from an "empty" queue and a "valid" queue, and copy the data from one block to the other.
    • Some threads memory copy the data. 一些執行緒負責資料拷貝
    • Some threads invert the data in place. 一些執行緒負責資料插入
    • Some threads write the data to disk, and read it to the new location. 一些執行緒負責資料寫入和讀出
  • After the specified time has elapsed, all "valid" pages have their data compared with the original fill pattern. 超過設定的時間,就會與初始資料進行比較

Caveats 警告

This test works by stressing system interfaces. It is good at catching memory signal integrity or setup and hold problems, memory controller and bus interface issues, and disk controller issues. It is moderately good at catching bad memory cells and cache coherency issues. It is not good at catching bad processors, bad physical media on disks, or problems that require periods of inactivity to manifest themselves. It is not a thorough test of OS internals. The test may cause marginal systems to become bricks if disk or memory errors cause hard drive corruption, or if the physical components overheat.

該軟體在測試系統介面方面比較好,可以評估一些記憶體訊號完整性或記憶體晶片,介面匯流排及磁碟方面的情況;但是對已經損壞的處理器,物理儲存裝置不具有檢查功能,在該條件下測試,可能會導致系統或驅動崩潰,以及晶片過熱。

Security Considerations

Someone running stressapptest on a live system could cause other applications to become extremely slow or unresponsive. 測試中會導致系統反應變慢

Logged information

stressapptest can output a logfile of miscompares detected during its execution. stressapptest cannot yet log reboot failures, or other failures not visible to user space.

整個執行過程可以輸出日誌記錄檔案。

下面介紹下其簡單的使用過程,由於本人使用的平臺不是很支援該軟體,所以具體的其它功能和詳細說明不好書寫和記錄。

1、下載該檔案包:stressapptest_1.0.4.orig.tar.gz

2、tar -xvf stressapptest_1.0.4.orig.tar.gz

3、進入該資料夾然後:

<span class="pun">./</span><span class="pln">configure
make
sudo make install</span>
配置過程中可能會報錯,缺少某些庫,例如: libaio.a, librt.a (libaio.a: libaio-dev librt.a: libc6-dev);只需在網上查詢下對應的庫檔案,然後連網更新下載便可,然後再編譯,一般都可以通過;

也有可能cpu支援不同,如出現下述情況:

[python]view plaincopy
  1. root@LOonux:~/test/stressapptest-1.0.4#make
  2. Makingallinsrc
  3. make[1]:正在進入目錄`/root/test/stressapptest-1.0.4/src'
  4. makeall-am
  5. make[2]:正在進入目錄`/root/test/stressapptest-1.0.4/src'
  6. g++-DHAVE_CONFIG_H-I.-DCHECKOPTS-Wreturn-type-Wunused-Wuninitialized-Wall-Wno-psabi-O3-funroll-all-loops-funroll-loops-DNDEBUG-MTmain.o-MD-MP-MF.deps/main.Tpo-c-omain.omain.cc
  7. Infileincludedfromfinelock_queue.h:29,
  8. fromsat.h:28,
  9. frommain.cc:18:
  10. os.h:131:4:warning:#warning"UnsupportedCPUtype:Unabletoforcecacheflushes."
  11. os.h:161:4:warning:#warning"UnsupportedCPUtype:yourbuildmaynotfunctioncorrectly"
  12. mv-f.deps/main.Tpo.deps/main.Po
  13. g++-DHAVE_CONFIG_H-I.-DCHECKOPTS-Wreturn-type-Wunused-Wuninitialized-Wall-Wno-psabi-O3-funroll-all-loops-funroll-loops-DNDEBUG-MTos.o-MD-MP-MF.deps/os.Tpo-c-oos.oos.cc
  14. Infileincludedfromos.cc:21:
  15. os.h:131:4:warning:#warning"UnsupportedCPUtype:Unabletoforcecacheflushes."
  16. os.h:161:4:warning:#warning"UnsupportedCPUtype:yourbuildmaynotfunctioncorrectly"
  17. os.cc:165:2:warning:#warning"UnsupportedCPUtype:unabletodeterminefeatureset."
  18. mv-f.deps/os.Tpo.deps/os.Po
目前支援的型別應該有下述三種,否則編譯出錯:

[python]view plaincopy
  1. casex"$target_cpu"in
  2. "xx86_64")
  3. $as_echo"#defineSTRESSAPPTEST_CPU_X86_64/**/">>confdefs.h
  4. ;;
  5. "xi686")
  6. $as_echo"#defineSTRESSAPPTEST_CPU_I686/**/">>confdefs.h
  7. ;;
  8. "xpowerpc")
  9. $as_echo"#defineSTRESSAPPTEST_CPU_PPC/**/">>confdefs.h
  10. ;;
  11. "xarmv7a")
安裝完成後,執行該軟體,可得記錄日誌如下:

例如 測試1200M大小的記憶體,測試300000秒的時間

[python]view plaincopy
  1. Log:Commandline-./stressapptest-M1200-s300000
  2. Stats:SATrevision1.0.1_autoconf,32bitbinary
  3. Log:root@RAYS-0bedc0f6onSunMar1418:59:09UTC2010fromopensourcerelease
  4. Log:1nodes,4cpus.
  5. Log:Defaultingto4copythreads
  6. Log:Flooringmemoryallocationtomultipleof4:1200MB
  7. Log:Usingmemalignedallocationat0x2b4d9000.
  8. Stats:StartingSAT,1200M,300000seconds
  9. Log:Regionmask:0x1
  10. Log:Secondsremaining:299990
  11. Log:Secondsremaining:299980
  12. Log:Secondsremaining:299970
  13. Log:Secondsremaining:299960
  14. Log:Secondsremaining:299950
  15. Log:Secondsremaining:299940
  16. Log:Secondsremaining:299930
  17. Log:Secondsremaining:299920
  18. Log:Secondsremaining:299910
  19. Log:Secondsremaining:299900
  20. Log:Secondsremaining:299890