Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Large numbers of Pinvoke stubs created on startup #11894

Closed
benaadams opened this issue Jan 25, 2019 · 7 comments
Closed

Large numbers of Pinvoke stubs created on startup #11894

benaadams opened this issue Jan 25, 2019 · 7 comments
Assignees
Milestone

Comments

@benaadams
Copy link
Member

@benaadams benaadams commented Jan 25, 2019

Using checked Jit and JitDasm (on Windows)

set COMPlus_JitDisasm=*

This program on current .NET Core 3.0

public class Program
{
    public static void Main(string[] args)
    {
        Console.WriteLine("Hello World!");
    }
}

Outputs 27 ILStubClass:IL_STUB_PInvoke

; Assembly listing for method ILStubClass:IL_STUB_PInvoke(struct,struct,bool)
; Assembly listing for method ILStubClass:IL_STUB_PInvoke(struct,long,int,struct)
; Assembly listing for method ILStubClass:IL_STUB_PInvoke(long,long,long)
; Assembly listing for method ILStubClass:IL_STUB_PInvoke(struct)
; Assembly listing for method ILStubClass:IL_STUB_PInvoke(ref,bool,struct)
; Assembly listing for method ILStubClass:IL_STUB_PInvoke(ref,struct)
; Assembly listing for method ILStubClass:IL_STUB_PInvoke(ref,struct)
; Assembly listing for method ILStubClass:IL_STUB_PInvoke(ref,byref,byref,byref,byref)
; Assembly listing for method ILStubClass:IL_STUB_PInvoke(ref,byref):bool
; Assembly listing for method ILStubClass:IL_STUB_PInvoke(ref,long,int):int
; Assembly listing for method ILStubClass:IL_STUB_PInvoke(ref):int
; Assembly listing for method ILStubClass:IL_STUB_PInvoke(ref):int
; Assembly listing for method ILStubClass:IL_STUB_PInvoke(ref,byref,byref)
; Assembly listing for method ILStubClass:IL_STUB_PInvoke():int
; Assembly listing for method ILStubClass:IL_STUB_PInvoke(byref,int,byref,long):int
; Assembly listing for method ILStubClass:IL_STUB_PInvoke(int,byref):bool
; Assembly listing for method ILStubClass:IL_STUB_PInvoke(ref,int,byref):bool
; Assembly listing for method ILStubClass:IL_STUB_PInvoke(long,int,ubyte):long
; Assembly listing for method ILStubClass:IL_STUB_PInvoke(byref,int,long):bool
; Assembly listing for method ILStubClass:IL_STUB_PInvoke(byref):bool
; Assembly listing for method ILStubClass:IL_STUB_PInvoke(int,int):ref
; Assembly listing for method ILStubClass:IL_STUB_PInvoke(int):long
; Assembly listing for method ILStubClass:IL_STUB_PInvoke(long,long,int,byref,long):int
; Assembly listing for method ILStubClass:IL_STUB_PInvoke():int
; Assembly listing for method ILStubClass:IL_STUB_PInvoke(long):int
; Assembly listing for method ILStubClass:IL_STUB_PInvoke():bool
; Assembly listing for method ILStubClass:IL_STUB_PInvoke(ref,int,long,int):int

Not sure if this is expected, am sure it was less?

/cc @jkotas

Is it Tiered Jit related? /cc @kouvel

@benaadams
Copy link
Member Author

@benaadams benaadams commented Jan 25, 2019

Looks like it was 5 IL_STUB_PInvoke previously on Windows rather than 27 (according to this issue https://github.com/dotnet/coreclr/issues/13129) /cc @AndyAyersMS

@jkotas
Copy link
Member

@jkotas jkotas commented Jan 25, 2019

This is side-effect of dotnet/coreclr#21497. The PInvoke stubs are on the list of follow-up work. cc @fadimounir

@sandreenko
Copy link
Contributor

@sandreenko sandreenko commented Jan 25, 2019

#11846 looks like the same issue.

@jkotas
Copy link
Member

@jkotas jkotas commented Jan 25, 2019

#11846 looks like the same issue.

Why do you think so? A method takes between ~0.1ms to compile on fast hardware and 1ms on slow hardware. So the times you are talking about here are between 5ms and 50ms. Orders of magnitude different from the times in #11846.

@sandreenko
Copy link
Contributor

@sandreenko sandreenko commented Jan 25, 2019

Why do you think so? A method takes between ~0.1ms to compile on fast hardware and 1ms on slow hardware. So the times you are talking about here are between 5ms and 50ms. Orders of magnitude different from the times in #11846.

Answered in #11846 (in case if this is a different issue).

@AndyAyersMS
Copy link
Member

@AndyAyersMS AndyAyersMS commented Jan 25, 2019

Stubs are pretty small, I would not expect having to jit a few more to matter very much.

Also don't CoreFX tests all run in one process (or maybe a handful of processes at best)? If so presumably any "fixed cost" jit overhead washes out.

@fadimounir
Copy link
Contributor

@fadimounir fadimounir commented Apr 19, 2019

Fixed

@msftgits msftgits transferred this issue from dotnet/coreclr Jan 31, 2020
@msftgits msftgits added this to the 3.0 milestone Jan 31, 2020
@msftbot msftbot bot locked as resolved and limited conversation to collaborators Dec 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
6 participants