Try   HackMD

2016q3 Homework1(phonebook)

Reviewed by believe7028

  • 可以對 perf 所量測得到的信息做說明更細緻的解釋,以及是否有其他事件數據可說明程式的狀況。
  • 除了縮小資料結構的大小,可以採用如雜湊等方法增加搜尋的效能。
  • 如果未來資料一直增長,Linked list 可能無法在記憶體放所有資料。
  • 可以加入刪除的功能以符合實際的需求。
  • git log message 可以更明確指出做了什麼動作(mody xxx),並且增加細部的說明(the xxx because ),讓開頭主題簡潔明確。

開發環境

  • Linux核心:Linux version 3.19.0-25-generic

準備工作

  • Lubuntu

    • 雙螢幕設定:終端機輸入
    ​sudo apt-get update		# 更新套件庫
    ​sudo apt-get install disper	# 安裝disper
    ​disper -d auto -e -t right	# 向右延伸桌面
    
    • 使用LVPM擴充Lubuntu佔用的空間,改用新的root.disk檔重新開機後出現以下提示
    ​[Minimal BASH-like line editing is supported. for the first word,
    ​TAB lists possible command completions. Anywhere else TABlists 
    ​the possible completions of a device/filename.]
    ​grub>
    

    換回舊的root.disk檔 能正常開機 Lubuntu在C槽中所站空間的確依照空間提昇
    但Lubuntu系統能使用的空間依然為括充前的容量

  • github

    • 生成 SSH 公開金鑰: 成大wiki相關參考資料的step 6中提到的指令無法生成SSH Key
      改成以下指令即可
    ​$ cat ~/.ssh/id_rsa.pub	
    
    • 練習
      Image Not Showing Possible Reasons
      • The image file may be corrupted
      • The server hosting the image is unavailable
      • The image path is incorrect
      • The image format is not supported
      Learn More →
      • clone 從別人那裡fork來的專案 不用init,skip step.4
      • clone 下來的不用remote ,skip step.11,直接輸入 git push
  • 參考資料

原始版本

  • 執行結果
    ​size of entry : 136 bytes
    ​execution time of append() : 0.077054 sec
    ​execution time of findName() : 0.006564 sec
    ​3
    
  • Perf 檢視catch miss
    ​$ make cache-test
    
    • 結果
    ​Performance counter stats for './phonebook_orig' (100 runs):
    
    ​​​​     1,986,847      cache-misses              #   89.834 % of all cache refs      ( +-  0.11% )
    ​​​​     2,211,677      cache-references                                              ( +-  0.12% )
    ​​​​   262,179,442      instructions              #    1.35  insns per cycle          ( +-  0.02% )
    ​​​​   194,202,618      cycles                     ( +-  0.33% )
    
    ​​​​   0.090345079 seconds time elapsed                                          ( +-  0.97% )
    

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

方法一:改變結構,使entry size變小

  • 從phonebook中搜尋資料 以lastname作為索引 所以所以一開始 cache中有lastname即可
    不需要將所有細節資料全部載入

    ​typedef struct __LAST_NAME_ENTRY { ​ char lastName[MAX_LAST_NAME_SIZE]; ​​​​ __PHONE_BOOK_DETAIL *pDetail; ​​​​ struct __LAST_NAME_ENTRY *pNext; ​} entry; ​
  • 執行結果

    ​​size of entry : 32 bytes
    ​execution time of append() : 0.068336 sec
    ​execution time of findName() : 0.003898 sec
    ​3
    
  • Perf檢視cache miss

    ​$ make cache-test
    
    ​Performance counter stats for './phonebook_opt' (100 runs):
    
    ​​​​       334,859      cache-misses              #   58.245 % of all cache refs      ( +-  0.26% )
    ​​​​       574,913      cache-references                                              ( +-  0.31% )
    ​​​​   245,984,198      instructions              #    1.73  insns per cycle          ( +-  0.02% )
    ​​​​   142,449,286      cycles                     ( +-  0.14% )
    
    ​​​​   0.071604653 seconds time elapsed                                          ( +-  0.97% )
    

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

這圖片是錯的!沒反映程式執行時間的變化,請改正 jserv
phonebook_opt.h 中的 #define OPT1 註解取消掉 , 因為實驗室電腦lubuntu系統被我玩壞了 ,所以改成用別台電腦的 linux mint 作業系統做作業,謝謝老師在作業上的提點
LitSnow