-
Notifications
You must be signed in to change notification settings - Fork 13
Add thapi_start()/stop() for localized profiling
#326
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
Conversation
thapi_profile_start() and thapi_profile_stop() for localized profilingthapi_profiler_start()/stop() for localized profiling
|
Please fix the I think we can shorten the name to For the name of the event, I think I prefer |
|
Also if you don't mind adding a tests in Easier than to put a "real" test (aka |
|
Nice! You may just need to specify the |
52ebcf3 to
99b97e4
Compare
1d62337 to
799c8ff
Compare
|
So the following #!/usr/bin/env bats
setup_file() {
export THAPI_HOME=$PWD/ici
export IPROF=$THAPI_HOME/bin/iprof
export THAPI_INC_DIR=$THAPI_HOME/include
export THAPI_LIB_DIR=$THAPI_HOME/lib
}
teardown_file() {
rm -rf $THAPI_HOME/thapi-traces
}
@test "thapi_start_stop" {
cc -I${THAPI_INC_DIR} ./integration_tests/thapi_start_stop.c -o thapi_start_stop \
-Wl,-rpath,${THAPI_LIB_DIR} -L${THAPI_LIB_DIR} -lThapi
$IPROF --no-analysis -- ./thapi_start_stop
start_count=`babeltrace2 $THAPI_HOME/thapi-traces | grep lttng_ust_toggle:start | wc -l`
[ "$start_count" -eq 1 ]
stop_count=`babeltrace2 $THAPI_HOME/thapi-traces | grep lttng_ust_toggle:stop | wc -l`
[ "$stop_count" -eq 2 ]
}Then I do: bats general.batsand I get: So, the |
I guess it is me who told you to merge the two definitions? But yeah, this is why we have a CI. So easy to introduce a bug! |
Haha -- but I doubt that is the issue -- but I will take a closer look. |
799c8ff to
8eb0eae
Compare
424ba5a to
fb4c875
Compare
|
(don't worry about the failing test) |
|
I played a bit with I didn't register any callbacks and only made the following changes in the generated boilerplate index cdec2b5..902e148 100644
--- a/./btx_filter/btx_main.c
+++ b/../btx_filter_main.c
@@ -22,6 +22,9 @@
* |_ o ._ _. | o _ _
* | | | | (_| | | /_ (/_
*/
+
+static bool toggle_on = false;
+
static inline bt_message_iterator_class_next_method_status
filter_message_iterator_next_finalizing(
bt_self_message_iterator *self_message_iterator,
@@ -109,14 +112,12 @@ static inline void filter_message_iterator_next_call_dispatchers(
/* Event dispatcher */
const char *class_name = bt_event_class_get_name(event_class);
- name_to_dispatcher_t *s = NULL;
- HASH_FIND_STR(common_data->name_to_dispatcher, class_name, s);
- if (s) {
- (*((dispatcher_t(*))(s->dispatcher)))(s->callbacks, common_data,
- upstream_message);
+ bool toggle = (strncmp(class_name, "lttng_ust_toggle", 16) == 0);
+ if (toggle) {
/* Drop message */
+ toggle_on = (strncmp(class_name, "lttng_ust_toggle:start", 32) == 0);
bt_message_put_ref(upstream_message);
- } else {
+ } else if (toggle_on) {
/* Push upstream message to downstream */
btx_downstream_push_message(message_iterator_private_data,
upstream_message);Seems like we can avoid having to generate a |
9ee720f to
255eccb
Compare
thapi_profiler_start()/stop() for localized profilingthapi_start()/stop() for localized profiling
97c9ce9 to
f66fc28
Compare
45d0f89 to
f482f5e
Compare
We need one which supports __attribute__((constructor)) in user code.
Also, minor refactoring in utils/Makefile.am.
1b9122a to
b5a51de
Compare
b5a51de to
287066f
Compare
|
Closing this in favor of #454. |
I created
lttng_ust_profilerlttng_ust_toggleevent category and namespace'd user APIwith
thapi_profiler_*thapi_(in a similar spirit tocudaProfilerStart()etc.). The librarywhich the user has to link against is named
libThapiProfiler.solibThapi.so.Usage of the API is as follows:
If
libThapiProfiler.solibThapi.sois linked,thapi_profiler_stop()thapi_stop()is calledautomatically during the library load time using
__attribute__((constructor)). I added a check inconfigure.acto check if the compiler supports__attribute__((constructor)).P.S: This feature requires
lttng-ust >= 2.12.8. Specifically, this fix.TODO
Respectlttng_ust_profiler_*lttng_ust_toggle_*events when calculating statisticsfilter.toggle.toggletobabeltracegraph