Skip to content

Instantly share code, notes, and snippets.

@vchirikov
Last active August 23, 2019 10:01
Show Gist options
  • Save vchirikov/26db927c252fccfeeb0605ae1066e36d to your computer and use it in GitHub Desktop.
Save vchirikov/26db927c252fccfeeb0605ae1066e36d to your computer and use it in GitHub Desktop.
CLR Fusion log collection
@echo off
SET PERFVIEW=C:\tools\PerfView64.exe
SET FUSLOGPATH=%~dp0
echo Press enter when ready to start collection...
pause
reg add HKLM\Software\Microsoft\Fusion /reg:64 /f /v EnableLog /t REG_DWORD /d 1
reg add HKLM\Software\Microsoft\Fusion /reg:64 /f /v LogFailures /t REG_DWORD /d 1
reg add HKLM\Software\Microsoft\Fusion /reg:64 /f /v LogResourceBinds /t REG_DWORD /d 0
reg add HKLM\Software\Microsoft\Fusion /reg:64 /f /v LogPath /t REG_SZ /d %FUSLOGPATH%
reg add HKLM\Software\Microsoft\Fusion /reg:32 /f /v EnableLog /t REG_DWORD /d 1
reg add HKLM\Software\Microsoft\Fusion /reg:32 /f /v LogFailures /t REG_DWORD /d 1
reg add HKLM\Software\Microsoft\Fusion /reg:32 /f /v LogResourceBinds /t REG_DWORD /d 0
reg add HKLM\Software\Microsoft\Fusion /reg:32 /f /v LogPath /t REG_SZ /d %FUSLOGPATH%
echo %FUSLOGPATH%
echo ...Capturing...
echo Press enter key when you want to stop...(also close opened cmd)
start cmd /c %PERFVIEW% /nogui /accepteula /NoRundown /NoV2Rundown /NoNGenRundown /NoClrRundown /NoView /LogFile:PerfViewCollect.log /BufferSizeMB:4096 /CircularMB:2000 /CollectMultiple:100 /DelayAfterTriggerSec:0 /KernelEvents:Process -TplEvents:None /onlyProviders="clrPrivate:0x2:Informational" /ClrEvents:All /Merge:true /Zip:true collect fusion.etl
rem we can use `/onlyProviders=clrPrivate:0:Informational:@EventIDsToEnable=196 collect` for enable only FusionMessages (by event field ID)
pause
echo ...Stopping...
reg add HKLM\Software\Microsoft\Fusion /reg:64 /f /v EnableLog /t REG_DWORD /d 0
reg add HKLM\Software\Microsoft\Fusion /reg:64 /f /v LogFailures /t REG_DWORD /d 0
reg add HKLM\Software\Microsoft\Fusion /reg:64 /f /v LogResourceBinds /t REG_DWORD /d 0
reg add HKLM\Software\Microsoft\Fusion /reg:32 /f /v EnableLog /t REG_DWORD /d 0
reg add HKLM\Software\Microsoft\Fusion /reg:32 /f /v LogFailures /t REG_DWORD /d 0
reg add HKLM\Software\Microsoft\Fusion /reg:32 /f /v LogResourceBinds /t REG_DWORD /d 0
%PERFVIEW% abort /accepteula /LogFile:PerfViewCollect.log
timeout /t 2
echo ...Viewing...
start cmd /c %PERFVIEW% /accepteula fusion.etl
@vchirikov
Copy link
Author

I enabled /ClrEvents:All, because can't get fusion log messages in result file with another options :(
Also fusion log writed to current directory for fusion.bat. Can be usefully too.
See also: microsoft/perfview#805

@vchirikov
Copy link
Author

Updated: we can use /onlyProviders=clrPrivate:0:Informational:@EventIDsToEnable=196 collect for enable only FusionMessage log.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment