chrome 高cpu占用 性能分析 原因查找

Visual Studio 性能探查器

Windows Performance Toolkit

PerfView 应该只能用于.NET

尝试了chrome://tracing/,但是暂时没太看懂里面都是什么意思

 


 

搜着搜着发现了一个UIforETW,这个好像是专门用于chrome的Event Tracing for Windows (ETW),所以试用了一下

 

 

 

msiexec.exe /i "C:\Users\\Downloads\etwpackage1.58\etwpackage\third_party\wpt10\WPTx64 (OnecoreUAP)-x64_en-us.msi"
msiexec.exe /i "C:\Users\\Downloads\etwpackage1.58\etwpackage\third_party\wpt10\WPTx64 (DesktopEditions)-x64_en-us.msi"
WPT version 10.0.22621.755 was installed.

Setting _NT_SYMBOL_PATH=SRV*C:\symbols*https://msdl.microsoft.com/download/symbols (Microsoft). Set _NT_SYMBOL_PATH yourself or toggle 'Chrome developer' if you want different defaults.

Setting _NT_SYMBOL_PATH=SRV*C:\symbols*https://msdl.microsoft.com/download/symbols;SRV*C:\symbols*https://chromium-browser-symsrv.commondatastorage.googleapis.com (Microsoft plus Chrome). Set _NT_SYMBOL_PATH yourself or toggle 'Chrome developer' if you want different defaults.(这里需要自己设置 符号服务器环境变量 ,我以为是自动设置的)


Starting tracing to disk...
Tracing is started.

Saving trace to disk...
The trace you have just captured "C:\Users\\AppData\Local\Temp\UIForETWkernel.etl" may contain personally identifiable information, including but not necessarily limited to paths to files accessed, paths to registry accessed and process names. Exact information depends on the events that were logged. Please be aware of this when sharing out this trace with other people.
The trace you have just captured "C:\Users\\AppData\Local\Temp\UIForETWuser.etl" may contain personally identifiable information, including but not necessarily limited to paths to files accessed, paths to registry accessed and process names. Exact information depends on the events that were logged. Please be aware of this when sharing out this trace with other people.
Merging trace...
Merged Etl: C:\Users\\Documents\etwtraces\2023-05-03_12-38-18_.etl
Preprocessing trace to identify Chrome processes and summarize CPU usage. This may take a little while...
Finished recording trace.

Copied chrome_regions_of_interest.xml to the WPA Files directory.
Copied Startup10.wpaProfile to %localappdata%\Windows Performance Analyzer

 

打开Windows Performance Analyzer(wpa.exe)

配置符号服务器路径,然后点击Loading symbols


SimpleWatcher

Thread-safe Context object used to schedule trap events from arbitrary threads.

 

 

mojom

Mojo 是一个跨平台 IPC 框架,它诞生于 chromium ,用来实现 chromium 进程内/进程间的通信。目前,它也被用于 ChromeOS。

Mojom
Mojo在Binding层中引入了 Mojom 这种IDL语言,用它来定义接口。接口定义文件的后缀一般为 .mojom

 

https://source.chromium.org/search?q=FindRegistrationForScope%20ForwardToCallback

https://source.chromium.org/chromium/chromium/src/+/main:out/win-Debug/gen/components/services/storage/public/mojom/service_worker_storage_control.mojom-blink.cc;drc=f186aea6577a96ca4014e7b465b2b605e800ef55;l=2840

class ServiceWorkerStorageControl_FindRegistrationForScope_ForwardToCallback

 看来大概率是ServiceWorker相关的原因

 


 

关于https://source.chromium.org/chromium/chromium/src/+/main:out/ out这个路径

这个git存储库的存在是为了允许在Chromium构建过程中生成的源文件通过代码搜索被索引。

 

 

 

 

 chrome.dll!base::internal::Invoker<base::internal::BindState<void (mojo::SimpleWatcher::*)(int, unsigned int, const mojo::HandleSignalsState &),base::WeakPtr<mojo::SimpleWatcher>,int,unsigned int,mojo::HandleSignalsState>,void ()>::RunOnce

chrome.dll!base::internal::Invoker<base::internal::BindState<void (mojo::Connector::*)(unsigned int),base::internal::UnretainedWrapper<mojo::Connector> >,void (unsigned int)>::Run

chrome.dll!base::internal::Invoker<base::internal::BindState<base::OnceCallback<void (mojo::StructPtr<storage::mojom::ServiceWorkerRegistrationData>, std::__1::unique_ptr<std::__1::vector<mojo::StructPtr<storage::mojom::ServiceWorkerResourceRecord>,std::__1::allocator<mojo::StructPtr<storage::mojom::ServiceWorkerResourceRecord> > >,std::__1::default_delete<std::__1::vector<mojo::StructPtr<storage::mojom::ServiceWorkerResourceRecord>,std::__1::allocator<mojo::StructPtr<storage::mojom::ServiceWorkerResourceRecord> > > > >, storage::mojom::ServiceWorkerDatabaseStatus)>,mojo::StructPtr<storage::mojom::ServiceWorkerRegistrationData>,std::__1::unique_ptr<std::__1::vector<mojo::StructPtr<storage::mojom::ServiceWorkerResourceRecord>,std::__1::allocator<mojo::StructPtr<storage::mojom::ServiceWorkerResourceRecord> > >,std::__1::default_delete<std::__1::vector<mojo::StructPtr<storage::mojom::ServiceWorkerResourceRecord>,std::__1::allocator<mojo::StructPtr<storage::mojom::ServiceWorkerResourceRecord> > > > >,storage::mojom::ServiceWorkerDatabaseStatus>,void ()>::RunOnce

 

 

 

 

dwm.exe - 788 context switches, 169.38 ms CPU
svchost (FrameServer) - 6 context switches, 0.46 ms CPU
System - 8797 context switches, 816.11 ms CPU

Chrome PIDs by process type:
C:\Program Files\Google\Chrome\Application\chrome.exe (16356) - 208517 context switches, 19691.79 ms CPU, 74 processes
browser :
16356 - 204526 context switches, 19227.53 ms CPU
crashpad :
13524 - 6 context switches, 0.32 ms CPU
extension : total - 855 context switches, 219.28 ms CPU
1116 - 18 context switches, 1.19 ms CPU
1596 - 5 context switches, 0.45 ms CPU
1764 - 6 context switches, 0.42 ms CPU
2244 - 183 context switches, 20.99 ms CPU
5352 - 5 context switches, 0.41 ms CPU
5596 - 5 context switches, 0.41 ms CPU
7516 - 5 context switches, 0.43 ms CPU
7796 - 135 context switches, 23.86 ms CPU
8912 - 8 context switches, 0.54 ms CPU
12292 - 5 context switches, 0.42 ms CPU
13108 - 9 context switches, 0.55 ms CPU
13116 - 7 context switches, 0.47 ms CPU
13360 - 5 context switches, 0.50 ms CPU
14064 - 7 context switches, 0.49 ms CPU
15996 - 5 context switches, 0.51 ms CPU
16208 - 5 context switches, 0.51 ms CPU
17760 - 8 context switches, 0.45 ms CPU
17812 - 13 context switches, 1.27 ms CPU
17904 - 9 context switches, 0.46 ms CPU
17912 - 6 context switches, 0.52 ms CPU
21232 - 29 context switches, 0.95 ms CPU
23312 - 377 context switches, 163.48 ms CPU
gpu-process :
2236 - 2141 context switches, 161.78 ms CPU
renderer : total - 759 context switches, 48.10 ms CPU
300 - 46 context switches, 2.82 ms CPU
1640 - 9 context switches, 0.58 ms CPU
1984 - 22 context switches, 1.34 ms CPU
2696 - 10 context switches, 0.80 ms CPU
2916 - 9 context switches, 0.57 ms CPU
3032 - 9 context switches, 0.61 ms CPU
3316 - 10 context switches, 0.65 ms CPU
4560 - 15 context switches, 0.73 ms CPU
5936 - 14 context switches, 0.77 ms CPU
6400 - 25 context switches, 0.98 ms CPU
7456 - 16 context switches, 0.73 ms CPU
9776 - 14 context switches, 0.71 ms CPU
9784 - 16 context switches, 0.86 ms CPU
10260 - 10 context switches, 0.57 ms CPU
11748 - 25 context switches, 1.40 ms CPU
12368 - 14 context switches, 0.66 ms CPU
14080 - 52 context switches, 5.01 ms CPU
14128 - 14 context switches, 0.68 ms CPU
14348 - 10 context switches, 0.72 ms CPU
14912 - 14 context switches, 0.98 ms CPU
15448 - 9 context switches, 0.67 ms CPU
15572 - 6 context switches, 0.55 ms CPU
16432 - 14 context switches, 0.94 ms CPU
18008 - 12 context switches, 0.97 ms CPU
18888 - 7 context switches, 0.52 ms CPU
19176 - 12 context switches, 0.66 ms CPU
19652 - 11 context switches, 0.68 ms CPU
20128 - 22 context switches, 0.72 ms CPU
20956 - 24 context switches, 1.28 ms CPU
21268 - 13 context switches, 0.68 ms CPU
21480 - 13 context switches, 0.78 ms CPU
21616 - 30 context switches, 3.70 ms CPU
21828 - 14 context switches, 0.65 ms CPU
21832 - 15 context switches, 0.77 ms CPU
22372 - 14 context switches, 2.91 ms CPU
22976 - 20 context switches, 1.53 ms CPU
23896 - 13 context switches, 0.59 ms CPU
24116 - 7 context switches, 0.49 ms CPU
24244 - 10 context switches, 0.59 ms CPU
24364 - 63 context switches, 2.40 ms CPU
25152 - 12 context switches, 0.63 ms CPU
25268 - 5 context switches, 0.44 ms CPU
26244 - 11 context switches, 0.63 ms CPU
26392 - 28 context switches, 0.95 ms CPU
26636 - 9 context switches, 0.58 ms CPU
26820 - 11 context switches, 0.59 ms CPU
utility : total - 230 context switches, 34.77 ms CPU
84 - 213 context switches, 33.19 ms CPU (NetworkService)
12224 - 3 context switches, 0.21 ms CPU (AudioService)
18056 - 14 context switches, 1.37 ms CPU (StorageService)

 

 

删除ServiceWorker文件后(AppData\Local\Google\Chrome\User Data\Profile 1\Service Worker\CacheStorage),成功解决

(未成功解决。。。,最终发现,在chrome://serviceworker-internals 找到Running Status: RUNNING的,Stop或者Unregister,才解决;似乎是 沉浸式翻译这个扩展的原因 

 

 

chrome://serviceworker-internals/?devtools这里可以看到全部的各种网站注册了的serviceworker,可以看到

Scope: https://www.douyu.com/网站/域名 对应的术语是Scope
Registration ID: 554
Navigation preload enabled: false
Navigation preload header length: 4
Active worker:
Installation Status: ACTIVATED
Running Status: STOPPED
Fetch handler existence: EXISTS
Script: https://www.douyu.com/sw.js
Version ID: 1641
Renderer process ID: 0
Renderer thread ID: -1
DevTools agent route ID: -2
posted @ 2023-05-03 13:43  hrdom  阅读(405)  评论(0编辑  收藏  举报