-
Notifications
You must be signed in to change notification settings - Fork 2.6k
profiler changes for tiered compilation #14612
Conversation
|
|
||
| // Now that tiered compilation can create more than one jitted code version for the same rejit id | ||
| // we are arbitrarily choosing the first one to return. To return all of them we'd presumably need | ||
| // a new profiler API. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is still correct - we are arbitrarily choosing an implementation. The comment could also mention the new APIs you've added rather than refer to hypothetical new APIs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
|
||
| pCodeVersionManager->GetILCodeVersion(pMD, reJitId); | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets add another comment to indicate this is an arbitrarily chosen version and profilers are recommended to use GetILToNativeMapping3 to avoid that ambiguity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, sounds good
|
|
||
| /* | ||
| * GetNativeCodeStartAddresses | ||
| * |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO : )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops! Taken care of now
| ReJITID reJitId, | ||
| ULONG32 cCodeStartAddresses, | ||
| ULONG32 *pcCodeStartAddresses, | ||
| UINT_PTR codeStartAddresses[]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check out GetModuleInfo2 for example of how it deals with the variable size character buffer and the associated size in/out parameters. I know there aren't a ton of total examples in the profiler API and we already aren't strictly consistent which adds to the confusion, but I think GetModuleInfo2's behavior is a reasonable standard to emulate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I made it so that pcCodeStartAddresses and codeStartAddresses are optional. If that's not what you meant, let me know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking of the different ways you can call GetModuleInfo2 that don't work here yet:
- You can call with only pcchName/pcCodeStartAddresses non-null and receive the size of the buffer that would be needed (here this only works if the caller also allocated a sufficiently large buffer)
- You can call with pcchName/pcCodeStartAddresses null if you don't care about the size (looks like you still go to E_INVALIDARG in this case)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I see what you're saying now. I missed it the first time. I just updated it to be able to call with just with either pcCodeAddresses or codeStartAddresses null now and the other will be filled out appropriately
| CodeVersionManager *pCodeVersionManager = pMD->GetCodeVersionManager(); | ||
|
|
||
| ILCodeVersion ilCodeVersion = NULL; | ||
| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd put the entire enumeration under the lock. Did anything lead you to avoid putting it under the lock (we might want to change whatever that was too)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forgot to add the lock initially, then when I ran the tests only GetILCodeversion had an assert about the lock so I just put the it around that one place.
I have changed it to be around the whole enumeration now though
|
|
||
| /* | ||
| * GetILToNativeMapping3 | ||
| * |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another todo to do
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
src/vm/proftoeeinterfaceimpl.h
Outdated
|
|
||
| // end ICorProfilerInfo8 | ||
|
|
||
| // beging ICorProfiler9 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
begin ICorProfilerInfo9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, done
src/vm/proftoeeinterfaceimpl.h
Outdated
| ULONG32* pcCodeInfos, | ||
| COR_PRF_CODE_INFO codeInfos[]); | ||
|
|
||
| // end ICorProfiler9 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ICorProfilerInfo9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done too
| hr = ValidateParametersForGetCodeInfo(pMethodDesc, cCodeInfos, codeInfos); | ||
| if (SUCCEEDED(hr)) | ||
| { | ||
| CodeVersionManager* pCodeVersionManager = pMethodDesc->GetCodeVersionManager(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I notice a pre-existing bug - this code path didn't grab the code version manager lock and it needs to
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you run the tests with a debug build it should give you asserts anywhere you are missing the lock.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I haven't run the existing profiler tests yet, but in general I am running with debug coreclr so I should catch these once I do.
src/vm/proftoeeinterfaceimpl.cpp
Outdated
| pCodeVersionManager->GetILCodeVersion(pMD, reJitId); | ||
| } | ||
|
|
||
| NativeCodeVersionCollection nativeCodeVersions = ilCodeVersion.GetNativeCodeVersions(pMD); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The whole enumeration should be inside the lock (but you can leave the call to GetILtoNativeMapping3 outside of it)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, done
| else | ||
| { | ||
| for(ULONG32 i = 0; i < cCodeStartAddresses; ++i) | ||
| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You've got a buffer overrun here. cCodeAddresses can be larger than trueLen but addresses only has length trueLen.
|
LGTM, modulo that one remaining buffer overrun |
Adds new profiler APIs for tiered compilation support. Also as part of this change I updated ProfToEEInterfaceImpl::GetILToNativeMapping2 to properly respect the requested rejit ID.