-
Notifications
You must be signed in to change notification settings - Fork 790
[XPTI][INFRA] Refactored API implementations to improve performance #19160
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
Merged
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
a259407
[XPTI][INFRA] Fixed unit tests to reflect PR#18786
tovinkere 5db6dd1
[XPTI][INFRA] Improve XPTI performance by ~10-30% for API calls
tovinkere d630b70
[XPTI][INFRA] Fixed proxy library build issues
tovinkere f567d8b
Merge remote-tracking branch 'origin' into xpti_overheads
tovinkere 1bd95e4
[XPTI][INFRA] Fixed warnings
tovinkere 71657a0
[XPTI][INFRA] Fixed payload validity tests
tovinkere c81d27a
[XPTI][INFRA] Incorporated review suggestions
tovinkere 34a8ee0
Merge remote-tracking branch 'origin' into xpti_overheads
tovinkere File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,6 +56,8 @@ typedef void *xpti_plugin_function_t; | |
#endif | ||
|
||
namespace xpti { | ||
constexpr const char *g_unknown_function = "<unknown-function>"; | ||
constexpr const char *g_unknown_file = "<unknown-file>"; | ||
namespace utils { | ||
/// @class StringHelper | ||
/// @brief A helper class for string manipulations. | ||
|
@@ -575,12 +577,29 @@ inline std::string readMetadata(const metadata_t::value_type &MD) { | |
inline bool is_valid_payload(const xpti::payload_t *Payload) { | ||
if (!Payload) | ||
return false; | ||
else | ||
return (Payload->flags != 0) && | ||
((Payload->flags & | ||
static_cast<uint64_t>(payload_flag_t::SourceFileAvailable) || | ||
(Payload->flags & | ||
static_cast<uint64_t>(payload_flag_t::NameAvailable)))); | ||
else { | ||
bool isValid = false; | ||
bool hasSourceFile = | ||
(Payload->flags & | ||
static_cast<uint64_t>(payload_flag_t::SourceFileAvailable)) && | ||
Payload->source_file; | ||
bool hasName = (Payload->flags & | ||
static_cast<uint64_t>(payload_flag_t::NameAvailable)) && | ||
Payload->name; | ||
bool hasCodePtrVa = | ||
(Payload->flags & | ||
static_cast<uint64_t>(payload_flag_t::CodePointerAvailable)) && | ||
Payload->code_ptr_va; | ||
bool hasLineInfo = | ||
(Payload->flags & | ||
static_cast<uint64_t>(payload_flag_t::LineInfoAvailable)) && | ||
Payload->line_no != xpti::invalid_id<uint32_t>; | ||
// We ignore checking for column info as it may not always be available | ||
isValid = ((hasSourceFile && hasLineInfo) || hasName || hasCodePtrVa) && | ||
(Payload->flags != 0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. check There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed that the last test can go. |
||
|
||
return isValid; | ||
} | ||
} | ||
|
||
/// @brief Generates a default payload object with unknown details. | ||
|
@@ -595,11 +614,11 @@ inline bool is_valid_payload(const xpti::payload_t *Payload) { | |
/// | ||
/// @return A `xpti::payload_t` object with its members set to represent an | ||
/// unknown or unspecified payload. This includes setting the function name and | ||
/// file name to "unknown", line and column numbers to 0, and the module handle | ||
/// to nullptr. | ||
/// file name to "<unknown-function>" and "<unknown-file>" respectively, line | ||
/// and column numbers to 0, and the module handle to nullptr. | ||
/// | ||
inline xpti::payload_t unknown_payload() { | ||
xpti::payload_t Payload("unknown", "unknown-file", 0, 0, nullptr); | ||
xpti::payload_t Payload(g_unknown_function, g_unknown_file, 0, 0, nullptr); | ||
return Payload; | ||
} | ||
|
||
|
@@ -951,7 +970,8 @@ class tracepoint_scope_t { | |
/// @note MSFT compiler 2019/2022 support __builtin_FUNCTION() macro | ||
/// | ||
tracepoint_scope_t(const char *fileName, const char *funcName, int line, | ||
int column, bool selfNotify = false, | ||
int column, void *codePtrVa = nullptr, | ||
bool selfNotify = false, | ||
const char *callerFuncName = __builtin_FUNCTION()) | ||
: MTop(false), MSelfNotify(selfNotify), MCallerFuncName(callerFuncName) { | ||
if (!xptiTraceEnabled()) | ||
|
@@ -962,9 +982,9 @@ class tracepoint_scope_t { | |
if (!MData) { | ||
if (funcName && fileName) | ||
init(funcName, fileName, static_cast<uint32_t>(line), | ||
static_cast<uint32_t>(column)); | ||
static_cast<uint32_t>(column), codePtrVa); | ||
else | ||
init(callerFuncName, nullptr, 0u, 0u); | ||
init(callerFuncName, nullptr, 0u, 0u, codePtrVa); | ||
} else { | ||
MTraceEvent = MData->event_ref(); | ||
} | ||
|
@@ -1014,11 +1034,11 @@ class tracepoint_scope_t { | |
/// tracepoint data. | ||
/// | ||
void init(const char *FuncName, const char *FileName, uint32_t LineNo, | ||
uint32_t ColumnNo) { | ||
uint32_t ColumnNo, void *CodePtrVa) { | ||
// Register the payload and prepare the tracepoint data. The function | ||
// returns a UID, associated payload and trace event | ||
MData = const_cast<xpti_tracepoint_t *>( | ||
xptiRegisterTracepointScope(FuncName, FileName, LineNo, ColumnNo)); | ||
MData = const_cast<xpti_tracepoint_t *>(xptiRegisterTracepointScope( | ||
FuncName, FileName, LineNo, ColumnNo, CodePtrVa)); | ||
if (MData) { | ||
// Set the tracepoint scope with the prepared data so all nested functions | ||
// will have access to it; this call also sets the Universal ID separately | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
should we set source_file to invalid 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.
Initialization of the structure will set source_file = nullptr and "flags" = 0. So, it is safe. However, lines 568-569 can go as they are a part of initialization as well.