Using remote attach/command line Yourkit-2015-build-15550

Questions about YourKit .NET Profiler
Post Reply
yipkit
Posts: 2
Joined: Mon May 18, 2015 2:06 am

Using remote attach/command line Yourkit-2015-build-15550

Post by yipkit »

We used to just profile IIS web applications just by installing Yourkit (using build-15546) on the same server as the IIS. However, recenty we are trying to use these two methods:

1. Remote Attach to the yourkit agent running on the server (with the IIS)
2. Using the agent on that server to take cpu/memory profiling snapshot (much like the java way)

We kept on failing for the first one already. I could not get the port opening with this command:

YourkitTool64.exe enable port=10009
YourKit Profiler for .NET - Command line tool.
[YourKit Profiler 2015 for .NET - Build 15550] Log file: ******************\.ynp\log\YourKitTools64.exe-1084.log
Info: Trying to register DLL: "C:\Windows\syswow64\regsvr32.exe" /s "**************\YourKit-2015-build-15550-tools\YourKit-2
build-15550-tools\win32\ynpagent.dll"
Info: Trying to register DLL: "C:\Windows\system32\regsvr32.exe" /s "**************\YourKit-2015-build-15550-tools\YourKit-2
build-15550-tools\win64\ynpagent.dll"
Profiling has been enabled.

However, I do not see 10009 opened. In the log:
15550 0.002: Command line:
YourKitTools64.exe
enable
port=10009
15550 0.002: Executable:**************\YourKit-2015-build-15550-tools\YourKit-2015-build-15550-tools\YourKitTools64.exe
15550 0.002: Windows Server 2008 R2; version 6.1; 64-bit process
15550 0.004: hid: 16020D994943ZZ4Y10VVW519Y92YV2188W 64-bit machine
15550 0.004: Today is 20150518
15550 0.004: full_build_stamp: 15550 201504231114
15550 0.004: Agent library path: **************\YourKit-2015-build-15550-tools\win64\ynpagent.dll
15550 0.004: Reading startup options
15550 0.004: Environment variable YNP_STARTUP_OPTIONS: not defined
15550 0.004: Registry key HKLM\SOFTWARE\YNP\STARTUP_OPTIONS: port=10009
15550 0.004: CLR_Agent_OnLoad: options=port=10009
15550 0.005: y_setenv: COR_ENABLE_PROFILING=0
15550 0.005: Skipping **************\YourKit-2015-build-15550-tools\YourKit-2015-build-15550-tools\YourKitTools64.exe
15550 0.012: Command line:
YourKitTools64.exe
enable
port=10009
15550 0.012: Executable: **************\YourKit-2015-build-15550-tools\YourKit-2015-build-15550-tools\YourKitTools64.exe
15550 0.012: Windows Server 2008 R2; version 6.1; 64-bit process
15550 0.012: hid: 16020D994943ZZ4Y10VVW519Y92YV2188W 64-bit machine
15550 0.012: Today is 20150518
15550 0.012: full_build_stamp: 15550 201504231114
15550 0.012: Agent library path: **************\YourKit-2015-build-15550-tools\YourKit-2015-build-15550-tools\win64\ynpagent.dll
15550 0.012: [getRegistryStringValue] RegOpenKeyExW returned 2 key=software\microsoft\silverlight\Components\Debugging

Already set env variables:
Cor_Enable_Profiling=1
COR_PROFILER={75C0592D-F581-4C0F-9918-1B27C73DE09B}

What we are not sure is why in the log:
15550 0.005: y_setenv: COR_ENABLE_PROFILING=0

while we already set it to 1?

If you had faced the similar situation before, please advise.

Regarding the second question, how do we do local cpu/memory snapshot for IIS web applications? Do we need to attach to the w3wp.exe first? We tried:

set YNP_STARTUP_OPTIONS=port=10009
*********\YourKit-2015-build-15550-tools\YourKit-2015-build-15550-tools>YourKitTools64.exe attach 5128
[YourKit Profiler 2015 for .NET - Build 15550] Log file: ********\.ynp\log\YourKitTools64.exe-864.log
YourKit Profiler for .NET - Command line tool.
Attaching to PID: 5128
Error: Attach failed:
AttachProfiler failed: -2146233494

also failed :*(
Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

Re: Using remote attach/command line Yourkit-2015-build-1555

Post by Anton Katilin »

Hi,

The logs you've provided are from the YourKitTools64.exe, the tool to manage profiling, not the profiled application (IIS). "y_setenv: COR_ENABLE_PROFILING=0" tells that the processes, if any, started from it should not be profiled. So please simply ignore this line, it's not about IIS.

Instead, could you please check the logs in IIS's user's home directory.
Regarding the second question, how do we do local cpu/memory snapshot for IIS web applications? Do we need to attach to the w3wp.exe first? We tried:
Attaching is an alternative way to starting with the agent. If IIS has started with the agent, you don't need to attach.

IIS services should be restarted after you enable profiling. Please try to restart the machine.

Please also pay attention that using a fixed port does not allow more than one process to run with the profiler. That is, since you've enabled profiling globally, the first started process with use the port, but further won't be able to load the agent.
Please try without using the fixed port.

Best regards,
Anton
yipkit
Posts: 2
Joined: Mon May 18, 2015 2:06 am

Re: Using remote attach/command line Yourkit-2015-build-1555

Post by yipkit »

Thanks for help.

I did
YourkitTools64.exe enable
before I restarted the IIS. Now I am able to see:

...\YourKit-2015-build-15550-tools\YourKit-2015-build-15550-tools>YourKitTools64.exe status
[YourKit Profiler 2015 for .NET - Build 15550] Log file: C:\Users\...\.ynp\log\YourKitTools64.exe-6712.log
YourKit Profiler for .NET - Command line tool.
[YourKit Profiler 2015 for .NET - Build 15550] Log file: C:\Users\...\.ynp\log\YourKitTools64.exe-6712.log
32-bit agent DLL is registered: C:\....\YourKit-2015-build-15550-tools\YourKit-2015-build-15550-tools\win32\ynpagent
64-bit agent DLL is registered: C:\....\YourKit-2015-build-15550-tools\YourKit-2015-build-15550-tools\win64\ynpagent

The monitoring server is running.

Running .NET applications:

Name | PID | User | Profiler Status | Port
-------------------+-------------+-----------+-----------------------+-------
InetMgr.exe | 1496 64-bit | ....| Agent loaded on start | 10001
w3wp.exe | 5300 64-bit | .... | Ready for attach |
SCNotification.exe | 5588 32-bit | ....| Ready for attach |

Profiling of all processes that will start: enabled
Profiler startup options:

If I remote attach to 10001, should I be able to profile the web app hosted on IIS (I think so?), or should I remote to w3wp.exe instead? How come w3wp.exe has "Ready for attach" instead of "Profiler Status"? I probably misunderstood how Yourkit.NET is supposed to work with IIS, but please bear with my questions here!
Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

Re: Using remote attach/command line Yourkit-2015-build-1555

Post by Anton Katilin »

w3wp.exe | 5300 64-bit | .... | Ready for attach |
"Ready for attach" means that IIS did not start with the profiler agent. Otherwise you would see "Agent loaded on start".
I did
YourkitTools64.exe enable
before I restarted the IIS.
Please ensure you have re-started all IIS services. Restarting the machine should do this.

Actually, the profiler UI contains functionality to automatically restart all necessary IIS stuff, but it's not a part of the command line tool. We'll try adding it in the next build.
Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

Re: Using remote attach/command line Yourkit-2015-build-1555

Post by Anton Katilin »

We've just released build 15558:
https://www.yourkit.com/dotnet

Its YourKitTools64.exe has new command "restart-iis". Please use it after "enable".
Post Reply