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

[TieredCompilation] Virtual calls may be slower with tiering #11007

Closed
kouvel opened this issue Aug 30, 2018 · 2 comments
Closed

[TieredCompilation] Virtual calls may be slower with tiering #11007

kouvel opened this issue Aug 30, 2018 · 2 comments
Assignees
Milestone

Comments

@kouvel
Copy link
Member

kouvel commented Aug 30, 2018

With tiering, there is an extra precode that calls would have to go through in some cases. If the processor does not compensate for the extra indirection, virtual calls are slower (normal calls are too, but that overhead is more easily compensated for with inlining).

See https://github.com/dotnet/coreclr/issues/18361 for an example where virtual call overhead is significant in the measurement.

Considerations:

  • For virtual calls, I had prototyped using the virtual slot with an indirect call instead of the precode, and it eliminated the regression in the test case above. It looks like this would also close most of the steady-state perf gap in JitBench benchmarks between tiering, and full-opt JIT alone. The idea seems promising, it should be completed.
  • For normal calls, I had prototyped using an indirect call instead of jumping over a trampoline. There were marginal improvements during startup, when with tier 0 JIT there would be more calls than at steady-state, but nothing significant since R2R'ed code also does some inlining. Without R2R it may be more interesting.
@kouvel
Copy link
Member Author

kouvel commented Aug 30, 2018

A PerfView profile with the -ShowUnknownAddresses switch shows unnamed functions in callees:

Name                                                                                              	Inc %	     Inc	Exc %	   Exc
 fstest!Program+PerformanceTests+trivialTest@67-1.Invoke(class Microsoft.FSharp.Core.FSharpFunc`2)	 95.1	   6,390	 14.6	   983
+ fstest!Program+PerformanceTests+trivialTest@66.Invoke(int32)                                    	 21.6	   1,454	 21.6	 1,452
+ fstest!Program+PerformanceTests+trivialTest@67-2.Invoke(int64)                                  	 14.4	     971	 14.4	   970
+ fstest!Program+PerformanceTests+trivialTest@68-4.Invoke(int64)                                  	 14.1	     949	 14.1	   948
+ fstest!Program+PerformanceTests.arg@1(int32,class Microsoft.FSharp.Core.FSharpFunc`2)           	 10.4	     702	  0.0	     0
+ fstest!Program+PerformanceTests+trivialTest@69-5.Invoke(int64)                                  	  5.6	     378	  5.6	   377
+ ?!0x7ffd8f2f7508                                                                                	  5.2	     352	  5.2	   352
+ ?!0x7ffd8f2f74f0                                                                                	  3.6	     239	  3.6	   239
+ ?!0x7ffd8f2f6638                                                                                	  2.6	     172	  2.5	   171
+ ?!0x7ffd8f2f6650                                                                                	  2.3	     155	  2.3	   155

The unnamed functions are the extra precodes, they don't show up in the caller stacks of virtual functions because the precode jumps to the target. Names should be added for the precodes, this is covered by https://github.com/dotnet/coreclr/issues/18428.

@kouvel kouvel self-assigned this Nov 13, 2018
@kouvel
Copy link
Member Author

kouvel commented Jan 19, 2019

Fixed by dotnet/coreclr#21292

@kouvel kouvel closed this as completed Jan 19, 2019
@msftgits msftgits transferred this issue from dotnet/coreclr Jan 31, 2020
@msftgits msftgits added this to the 3.0 milestone Jan 31, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants