-
Notifications
You must be signed in to change notification settings - Fork 10
add C API for profiling #269
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
base: main
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #269 +/- ##
==========================================
+ Coverage 27.15% 28.61% +1.45%
==========================================
Files 190 191 +1
Lines 39174 39759 +585
Branches 14166 14308 +142
==========================================
+ Hits 10638 11377 +739
- Misses 27240 27350 +110
+ Partials 1296 1032 -264 ☔ View full report in Codecov by Sentry. |
src/realm/realm_c.h
Outdated
realm_region_instance_t dst_indirection_inst; // dst indirection instance (scatter) | ||
realm_field_id_t src_indirection_field; // field of indirection points | ||
realm_field_id_t dst_indirection_field; // field of indirection points | ||
realm_profiling_measurement_operation_copy_info_request_type_t |
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.
Can you move the comment so this isn't split into two lines?
And these type names are getting insanely long. Do we really need to call it "realm_profiling_measurement_x_y_z"? Can't we just call these "realm_prof_x_y_z" ?
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.
And you can combine copy_info_inst_info into just _copy_inst_info.
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.
Yeah, the name is too long. I renamed them to realm_profiling_x_y_z, just because personally I would prefer the full English words as it is easy to understand.
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.
Documentation makes it easier to understand. Most codes will shorten the type names significantly. We don't need full english names. Like in this case, the following is enough:
realm_prof_copy_info_t
There's no need to add request_type
or measurement_operation
, as it is just redundant and doesn't add any value that documentation wouldn't give.
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 measurement
isn’t very useful, so I removed it. However, it’s better to keep operation
(or op
)—I prefer operation
because we generally use full names elsewhere, e.g., instance
, processor
and etc, and this keeps the naming consistent. Having operation
makes it immediately clear that the profiling data comes from an operation. Similarly, profiling entries that start with instance
indicate that the data comes from instance creation or redistribution. Honestly, I think it’s easier to understand how to use the profiling measurements this way, rather than constantly referring back to the documentation to remember what each class represents. That’s why the C++ naming also starts with Operation
or Instance
.
Regarding realm_profiling_operation_copy_info_request_type_t
, I’m not sure how to shorten the name while still clearly indicating that it relates to copy_info
.
src/realm/realm_c.h
Outdated
|
||
typedef struct realm_profiling_measurement_operation_backtrace_symbol_st { | ||
char symbol[PMID_OP_BACKTRACE_SYMBOLS_MAX_LENGTH]; | ||
} realm_profiling_measurement_operation_backtrace_symbol_t; |
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.
Why do you have a structure for this? Do you really need one?
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.
because in c++, it is std::vector. Here, the caller will pass a realm_profiling_measurement_operation_backtrace_symbol_t*
, otherwise, they will have to pass an array of char symbol[PMID_OP_BACKTRACE_SYMBOLS_MAX_LENGTH];
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.
Yes, they would, and that's okay.
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.
But how should the caller know they need to use char symbol[PMID_OP_BACKTRACE_SYMBOLS_MAX_LENGTH];
. I think there are many advantages when warp it into a struct.
- Type safety. if we define a
realm_profiling_measurement_operation_backtrace_symbol_t symbols[N];
, then symbols[i] is clearly a symbol struct, not just a char*. Otherwise, the users will have to create an array of char[N * PMID_OP_BACKTRACE_SYMBOLS_MAX_LENGTH], and they have to carefully jumpPMID_OP_BACKTRACE_SYMBOLS_MAX_LENGTH
to access each symbol. - Encapsulation and readability. By wrapping the array in a struct, you can give it a meaningful name (symbol), making the code easier to read and maintain. Using an array of array is really hard to read.
- Compatibility with STL containers. Structs can be stored in std::vector, std::array, or other containers easily, e.g.
std::vector< realm_profiling_measurement_operation_backtrace_symbol_t > symbols;
I do not understand why you want to remove this struct.
744fc31
to
b4690c9
Compare
No description provided.