Repository navigation
Improve performance of RuntimeHelpers.GetMethodTable - #247
GrabYourPitchforks wants to merge 1 commit into
Conversation
|
/cc @AndyAyersMS @CarolEidt Do you two have any thoughts on this? Seems like a straightforward enough change, but wondered if you knew of any gotchas here. |
|
As always, it would be nice to teach the JIT to just optimize the existing code instead of adding workarounds like this. |
|
This workaround is adding 3 helper types. I guess it would be ok to just have IL intrinsic expansion for |
|
This seems like something that should be simple to fix in the jit, but last I time I investigated, it didn't look all that simple. Making this an intrinsic seems sensible. I don't know when we'll get around to addressing the issues in the jit. |
|
One thing I don't have a good read on is what would be the relative impact of a JIT-wide improvement vs a targeted improvement like what is proposed here. There have been other issues where we've opted to make targeted fixes because the pattern in question didn't appear frequently enough to justify the JIT work. The pattern in question here is "get a ref to an instance field, then immediately perform ref arithmetic." I don't know how commonly that occurs outside these RuntimeHelpers helper methods. |
|
I don't think it is all that common. Most of the code the JIT sees won't use However, code that ends up using Address mode formation is not as robust in the JIT as it is in native compilers and there are numerous open issues (eg dotnet/coreclr#5526, dotnet/coreclr#10737, dotnet/coreclr#11458, ...) with suggestions on how to improve. But none of these are small work items. |
|
In the latest iteration I implemented an IL intrinsic rather than declaring new types. Let me know if this is closer to what you're looking for. I confirmed the codegen is the same as the original iteration: no intermediate |
|
Something went horribly wrong with my repo and I can no longer make code changes to this PR. 😬 |
Some small perf improvements to
RuntimeHelpers.GetMethodTable. Previously the codegen looked like:Now the codegen looks like:
Below is the microbenchmark for pulling a
Span<byte>from aMemory<byte>backed by abyte[].It's not much, but it could help make a small dent if these APIs are a hot path in a loop.