Kestrelhttpserver: Kestrel Dasm

Created on 20 Aug 2016  路  5Comments  路  Source: aspnet/KestrelHttpServer

Produced this while looking at something else; might be interesting

Its ngen'd so caveats apply; Vector paths aren't taken and readonly statics aren't consts etc...
https://aoa.blob.core.windows.net/aspnet/Microsoft.AspNetCore.Server.Kestrel.dasm.txt

But should give flavour for what's inlined what's not, how things expand, what is converted to registers what not and why etc...

/cc @davidfowl @halter73 @cesarbs

Most helpful comment

Ok simplest path... Build coreclr checked and release (can keep using these till you want an new update of coreclr)

coreclr> build all x64 Checked Release skiptests

Build test app as win7-x64 standalone and publish

Copy all files from coreclr\bin\Product\Windows_NT.x64.Release and pdb to your standalone publish directory e.g. bin\Release\netcoreapp1.0\win7-x64\publish

Copy clrjit.dll over from checked coreclr\bin\Product\Windows_NT.x64.Checked into the same publish directory.

Set the enviorment vars
set COMPlus_JitPrintInlinedMethods=1
set COMPlus_JitDisasm=*

Run your standalone exe from the publish directory probably piping its output to a file > dasm.txt

You can also get the jit to only output a certain disassembly e.g. set COMPlus_JitDisasm=System.Generic.*

The jit will work in parallel, so wait for start up to complete before you try loading a page or the output will get interleaved.

All 5 comments

Cool. How did you create the ngen dasm?

Twist on https://github.com/dotnet/coreclr/pull/6634#issuecomment-238048694

_Prep_

  1. Build coreclr Checked
  2. Build jitutils https://github.com/dotnet/jitutils
  3. Build standalone app and publish (So it has all the dlls)
  4. Copy clrjit.dll from coreclr Checked (coreclr\bin\Product\Windows_NT.x64.Checked) over the one in publish dir

_Iterations_

  1. Build app, or lib (e.g. Kestrel)
  2. Copy dlls you want to examine over the ones in app publish dir
  3. at cmd set set COMPlus_JitPrintInlinedMethods=1
  4. run jit-dasm on publish directory (see below)
  5. Check the output text file

The command:

jit-dasm --platform MyAppbinReleasenetcoreapp1.0win7-x64publish --base MyAppbinReleasenetcoreapp1.0win7-x64publishcrossgen.exe --output M:outputKDNEW MyAppbinReleasenetcoreapp1.0win7-x64publishMicrosoft.AspNetCore.Server.Kestrel.dll

Would create a dasm file for Microsoft.AspNetCore.Server.Kestrel in M:\output\KDNEW\base

New info... so if you do the standalone app + publish, then copy the checked clrjit.dll over (Prep)

Then you can just set the set COMPlus_JitPrintInlinedMethods=1 flag and it will output all the inlines when you run it (won't do the dasm though).

Since its actually running it will take the vectors paths etc...

Also if you set set COMPlus_JitDisasm=* it will dump out all the jitted code when you run normally (using the checked clrjit.dll and everything else from clr Release)

Ok simplest path... Build coreclr checked and release (can keep using these till you want an new update of coreclr)

coreclr> build all x64 Checked Release skiptests

Build test app as win7-x64 standalone and publish

Copy all files from coreclr\bin\Product\Windows_NT.x64.Release and pdb to your standalone publish directory e.g. bin\Release\netcoreapp1.0\win7-x64\publish

Copy clrjit.dll over from checked coreclr\bin\Product\Windows_NT.x64.Checked into the same publish directory.

Set the enviorment vars
set COMPlus_JitPrintInlinedMethods=1
set COMPlus_JitDisasm=*

Run your standalone exe from the publish directory probably piping its output to a file > dasm.txt

You can also get the jit to only output a certain disassembly e.g. set COMPlus_JitDisasm=System.Generic.*

The jit will work in parallel, so wait for start up to complete before you try loading a page or the output will get interleaved.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

netcore-jroger picture netcore-jroger  路  7Comments

M-Curtis picture M-Curtis  路  3Comments

chtbof picture chtbof  路  3Comments

Tazer picture Tazer  路  4Comments

halter73 picture halter73  路  4Comments