[20181230]Git Bash啟動緩慢.txt

lfree發表於2018-12-31

[20181230]Git Bash啟動緩慢.txt


--//我在我的機器裡安裝了git bash,實際上就是在windows下使用git的環境,主要裡面的shell很像在linux下使用,

--//最近經常在家裡的測試環境使用,不過不知道從什麼時候開始啟動越來越慢(我大概有1年時間沒有使用它),每次啟動都以分鐘計算。

--//但是第2次啟動就快許多,一直沒時間探究原因,放假做一個探究看看。


1.啟動systeminternals自帶的Procmon.exe:

--//加入git bash的命令。

--//在filter 加入 process name=sh.exe

--//接著啟動git bash。


2.檢視Procmon.exe的輸出:

--//擷取其中一段:

"19:45:38.8691172","sh.exe","5556","ReadFile","C:\Users\Administrator\AppData\Local\Temp","SUCCESS","Offset: 3,014,656, Length: 4,096, I/O Flags: Non-cached, Paging I/O, Synchronous Paging I/O, Priority: Normal","3428"

"19:45:38.9018613","sh.exe","5556","ReadFile","C:\Users\Administrator\AppData\Local\Temp","SUCCESS","Offset: 942,080, Length: 4,096, I/O Flags: Non-cached, Paging I/O, Synchronous Paging I/O, Priority: Normal","3428"

"19:45:38.9188716","sh.exe","5556","QueryDirectory","C:\Users\Administrator\AppData\Local\Temp","SUCCESS","0: {D59E17DB-AF30-486c-B0D3-FFFE5A543C08}, 1: {D5A1B416-49D9-4a8c-B1B9-44A91154741C}.tmp, 2: {D5A582E2-E7F7-4c65-AFEA-BB4984279266}.tmp, 3: {D5B0B300-B036-4358-807D-F676DD3C5FF4}, 4: {D5B6BA25-B8E7-4c49-877F-447B1C84E836}.tmp, 5: {D5C758E6-89AB-4b27-A6A9-F865F19D29D3}.tmp, 6: {D5CD3CD7-CB6F-4017-8C59-19CBAC3DB2B3}, 7: {D5EF4169-E8AD-435E-B62C-25F9B68C409E}, 8: {D5FD8CB5-D0AA-48e1-AA6B-5310413FF689}.tmp, 9: {D600C6E9-992D-4a3c-8EC4-F713BAA68D60}, 10: {D60F47D2-B682-4b42-82D5-60256C15A59B}, 11: {D6169450-79D0-4b70-BE3B-70041F93F847}.tmp, 12: {D6332DE0-4DAD-4bc0-80C3-ED4D3274084E}, 13: {D652BF56-F74D-4000-A925-6D0F1B18FB44}.tmp, 14: {D66C0A42-D81A-40cc-BF29-06D653F691D2}.tmp, 15: {D69B75A6-4970-44f8-BBE2-6370A712A405}, 16: {D6A0D8AA-E57D-4679-8E32-E1FBD4830EC6}, 17: {D6AE0700-69C8-47f2-8068-784F0516EE0D}, 18: {D6C3FA25-8CD8-4b74-B8E6-BE7F9BDB1358}.tmp, 19: {D6C90D9C-D706-49e6-9DBF-40DEB6F59E1B}, 20: {D6CA449E-4AF4-4ef9-A74C-D61E55F00A66}.tmp, 21: {D6D74BD6-A680-4980-8481-8A4E82CAE27F}.tmp","3428"

"19:45:38.9398716","sh.exe","5556","ReadFile","C:\Users\Administrator\AppData\Local\Temp","SUCCESS","Offset: 4,251,648, Length: 4,096, I/O Flags: Non-cached, Paging I/O, Synchronous Paging I/O, Priority: Normal","3428"

"19:45:39.0587826","sh.exe","5556","ReadFile","C:\Users\Administrator\AppData\Local\Temp","SUCCESS","Offset: 2,220,032, Length: 4,096, I/O Flags: Non-cached, Paging I/O, Synchronous Paging I/O, Priority: Normal","3428"

"19:45:39.0988808","sh.exe","5556","ReadFile","C:\Users\Administrator\AppData\Local\Temp","SUCCESS","Offset: 3,858,432, Length: 4,096, I/O Flags: Non-cached, Paging I/O, Synchronous Paging I/O, Priority: Normal","3428"

"19:45:39.1216568","sh.exe","5556","QueryDirectory","C:\Users\Administrator\AppData\Local\Temp","SUCCESS","0: {D6DEC424-ECE4-441d-9AD5-4D57ED4FD231}.tmp, 1: {D6DED546-747B-4372-B68D-44BC22F7272E}.tmp, 2: {D6E12931-CECF-40b0-AD36-000D51F10C18}, 3: {D6E998CD-A6F9-4bd8-9F8B-69BB8D505081}, 4: {D6EA89B9-F6D1-4d53-AB41-7D6C5FB372D5}, 5: {D72D111D-55F4-46c9-A7E1-93DE7CE5A5F7}, 6: {D757364B-68E5-4b40-97A6-F195DCFB767F}, 7: {D761B700-23E9-4d1c-9C3E-C5DADBCC93ED}.tmp, 8: {D773C39B-D88C-472d-BB2E-AF8FBD1394C2}.tmp, 9: {D787365F-B1FC-428c-9729-F495D1B7F15A}.tmp, 10: {D787A5DF-CA22-4a15-87F5-F78D1093F262}, 11: {D792667A-E1F4-4687-B7A9-C21E4BB96BA7}.tmp, 12: {D797E205-C262-4161-A3F2-40F17147A694}, 13: {D7A2B64D-44C0-419a-B618-164985997650}, 14: {D7B3B8DB-7448-48b0-9075-D63160DC6CBB}, 15: {D7B3DCAA-B416-4618-9A33-F23B433E9901}, 16: {D7C7F0F0-310B-48c2-9494-5C9918F2CFC7}.tmp, 17: {D7C829B9-425B-4a93-909E-4A6AF7489A6D}, 18: {D7E10170-28A8-410c-86CD-9AA67CB201D2}.tmp, 19: {D7E9B7B8-EC3E-4209-B11D-44BB505F4A6D}, 20: {D8001ABD-7C77-4714-B8A9-DBEBBB992152}, 21: {D839B58E-56EF-4dec-82C6-BEBDE54C0543}","3428"

"19:45:39.1608374","sh.exe","5556","ReadFile","C:\Users\Administrator\AppData\Local\Temp","SUCCESS","Offset: 1,380,352, Length: 4,096, I/O Flags: Non-cached, Paging I/O, Synchronous Paging I/O, Priority: Normal","3428"

"19:45:39.2271118","sh.exe","5556","ReadFile","C:\Users\Administrator\AppData\Local\Temp","SUCCESS","Offset: 2,285,568, Length: 4,096, I/O Flags: Non-cached, Paging I/O, Synchronous Paging I/O, Priority: Normal","3428"

"19:45:39.2287863","sh.exe","5556","QueryDirectory","C:\Users\Administrator\AppData\Local\Temp","SUCCESS","0: {D841B214-9CBC-45e2-BE05-9FBBDB43B1CF}, 1: {D843F502-9E60-4862-B232-9E90B6C8D3B9}.tmp, 2: {D844F2F3-84D0-492e-9466-921F0B3F6DDA}.tmp, 3: {D857F1E6-0D8C-4a93-87C7-A6A3E4C16528}.tmp, 4: {D87BB503-DDF6-44db-B95D-2A8CC8642B71}, 5: {D8924AC5-EA32-400a-98FD-465D88875340}, 6: {D8A51EB1-8470-4d11-9772-9DA46928F60B}, 7: {D8B0E597-6785-4555-A2F3-8E1EF15868E9}.tmp, 8: {D8BFB95F-91B2-43e5-A55F-2B96B54FE4B1}.tmp, 9: {D8D2641C-6A29-4225-ACF0-F2DE49657A61}.tmp, 10: {D8D84C50-C065-43f1-93BC-0BF881745CB6}, 11: {D8EA527F-AFB0-4139-AC98-EB362C21CCD5}, 12: {D8EE99C1-7FBD-4a0c-B24A-C8C07B4F566C}, 13: {D909AD82-6C93-4a2d-8120-9B2133D631E7}, 14: {D9337CDA-1961-4dbd-8371-6AD766BB71ED}, 15: {D93EAC2C-D811-45e5-BA6E-8936B68139F0}.tmp, 16: {D95AE73B-52D9-4259-9D51-4DF90E50B31A}, 17: {D976BB0E-9E12-48f9-AD83-DA256A3840F7}.tmp, 18: {D978BBCD-94B5-4e58-97C5-FDD25251AE53}, 19: {D991073C-BD72-48e1-ABB6-8D4F25B23F04}, 20: {D99C00A1-BFB3-4566-AB4A-3C7C7B9D73AA}, 21: {D9AAF2A4-47FD-4ee7-BCB7-B6BF6125FE98}","3428"

"19:45:39.3042872","sh.exe","5556","ReadFile","C:\Users\Administrator\AppData\Local\Temp","SUCCESS","Offset: 1,708,032, Length: 4,096, I/O Flags: Non-cached, Paging I/O, Synchronous Paging I/O, Priority: Normal","3428"

"19:45:39.3483337","sh.exe","5556","ReadFile","C:\Users\Administrator\AppData\Local\Temp","SUCCESS","Offset: 3,293,184, Length: 4,096, I/O Flags: Non-cached, Paging I/O, Synchronous Paging I/O, Priority: Normal","3428"


--//原來不斷讀取C:\Users\Administrator\AppData\Local\Temp目錄的內容.從讀偏移可以看出目錄很大,每次僅僅讀取4096.

--//而且不是按照順序讀取,很明顯該目錄裡面的檔案垃圾太多.


C:\Users\Administrator\AppData\Local\Temp>dir *.*|wc

  13453   53918  855600


--//^_^,13XXX個檔案以及目錄.在刪除前我看了一些檔案的內容,估計都是程式異常退出留下的垃圾.

--//我個人一直認為windows不是什麼好的作業系統.


d:\>set | grep -i temp

TEMP=C:\Users\ADMINI~1\AppData\Local\Temp

TMP=C:\Users\ADMINI~1\AppData\Local\Temp


D:\>cd C:\Users\Administrator\AppData\Local\Temp

D:\>C:

C:\Users\Administrator\AppData\Local\Temp> rm -rf *

--//小心^_^.打入前仔細檢查目錄是否正常.


rm: baidu\baiduyunguanjia\at_20181230_1: Permission denied

....

rm: nso3e2a.tmp: Directory not empty

rm: nsy3E19.tmp: Permission denied

rm: Procmon64.exe: Permission denied

rm: ~DFCEABA9338A926B9A.TMP: Permission denied

--//一些檔案還不能清除,估計當前在使用它.看來以後要養成定期清除該目錄的好習慣.


3.再重新啟動機器,點選git bash,馬上進入,問題解決.真不知道為什麼git bash啟動為什麼要掃描該臨時目錄.

--//我最後修改環境變數,將它指向D:\temp.還有一種方法就是寫一個批處理,單獨使用某個臨時資料夾.例如:

$ cat sh.bat

@echo off

set TEMP=D:\temp

set TMP=D:\temp

D:\tools\git\bin\sh.exe --login -i


--//建立快捷方式,這樣啟動也很快.而且要注意定期清理該目錄.


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2287069/,如需轉載,請註明出處,否則將追究法律責任。

相關文章