microsoft / perfview

PerfView is a CPU and memory performance-analysis tool
http://channel9.msdn.com/Series/PerfView-Tutorial
MIT License
4.18k stars 710 forks source link

PerfViewCollect does not run on Windows Server Nano #1741

Open Alois-xx opened 2 years ago

Alois-xx commented 2 years ago

Has this ever anyone tried? Server Nano does not support STA Threads. The workaround is to switch to MTA. I can provide a PR? Who is using this? Also I have problems to resolve the image id events, because the docker for Windows containers use a vmsmb folder path which cannot be resolved?

[Loading symbols for \\?\vmsmb\vsmb-{dcc079ae-60ba-4d07-847c-3493609c0870}\25404689-4f55-56f1-ad55-5332c9e7232e\files\windows\system32\kernelbase.dll]
No PDB signature for \\?\vmsmb\vsmb-{dcc079ae-60ba-4d07-847c-3493609c0870}\25404689-4f55-56f1-ad55-5332c9e7232e\files\windows\system32\kernelbase.dll in trace.
The file \\?\vmsmb\vsmb-{dcc079ae-60ba-4d07-847c-3493609c0870}\25404689-4f55-56f1-ad55-5332c9e7232e\files\windows\system32\kernelbase.dll does not exist on the local machine
Attempting to convert \\?\vmsmb\vsmb-{dcc079ae-60ba-4d07-847c-3493609c0870}\25404689-4f55-56f1-ad55-5332c9e7232e\files\windows\system32\kernelbase.dll to a volume-based path in case the file inside of a container.
Unable to convert \\?\vmsmb\vsmb-{dcc079ae-60ba-4d07-847c-3493609c0870}\25404689-4f55-56f1-ad55-5332c9e7232e\files\windows\system32\kernelbase.dll to a volume-based path.
WARNING: could not find PDB signature of a 64 bit OS DLL.  Did you collect with a 32 bit version of XPERF?

Is anyone using ETW inside windows containers?

brianrob commented 2 years ago

I have not had an issue running PerfViewCollect inside of Nano server containers recently. Can you share the error that you're seeing?

The ImageID issues that you're seeing are known and need to be addressed in the OS. I don't have an ETA on this, or know how it will be addressed yet though.

AloisKraus commented 2 years ago

The error message is:

C:\C\Source\Git\perfView_Branch\perfview\src\PerfViewCollect\bin\Release\netcoreapp3.1\win-x64>PerfViewCollect.exe
Unhandled exception. System.PlatformNotSupportedException: The system does not support the STA thread apartment.

I have created a default .NET 6.0 Web Service where I have replaced the default image with the nano image:

#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

#FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
FROM mcr.microsoft.com/dotnet/aspnet:6.0-nanoserver-1809 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["AspNetCoreWebAPI.csproj", "."]
RUN dotnet restore "./AspNetCoreWebAPI.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet build "AspNetCoreWebAPI.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "AspNetCoreWebAPI.csproj" -c Release -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "AspNetCoreWebAPI.dll"]

To get into the container with the self built binary I have used hcsdiag. Where I can search for the docker container ID which is the first part of the much longer hcsdiag container id. Then I can share folders and open a shell there.

Not sure if that is the recommended approach but that seems to be quick. Any pointers to a more docker like solutions are welcome.

C>docker ps
CONTAINER ID   IMAGE                  COMMAND                    CREATED          STATUS          PORTS                                           NAMES
7238ffbe22fe   aspnetcorewebapi:dev   "C:\\remote_debugger\\…"   37 seconds ago   Up 34 seconds   0.0.0.0:60416->80/tcp, 0.0.0.0:60415->443/tcp   AspNetCoreWebAPI

C>hcsdiag list | findstr /i 7238ffbe22fe
7238ffbe22fe0b9216b0cc796dfdaca56826102a903248161ff58fa0e56435e9

C>hcsdiag share 7238ffbe22fe0b9216b0cc796dfdaca56826102a903248161ff58fa0e56435e9 C:\ C:\C

C>hcsdiag shell 7238ffbe22fe0b9216b0cc796dfdaca56826102a903248161ff58fa0e56435e9
Copyright (c) Microsoft Corporation. All rights reserved.

The number of people using this seems to be near zero. @brianrob: Would it help if I create an official issue for enterprise customers with regards to the ImageID events? At some point ETW tracing is needed and I have no idea how one is supposed to get profiling data from a Windows Container running .NET Core 6.0 or later. If this ever hits production in the current state we will have huge issues.

brianrob commented 2 years ago

Thanks for sharing this. You are welcome to create an issue regarding the ImageID events. I have sent an e-mail to check on status, but feel free to file something if you like.

Regarding the threading issue, I have not seen this, but your PR to not use STA threads seems like a reasonable way to fix this, given that there's no GUI anyway.