Large performance improvement by caching event class name and id
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 3 Nov 2016 20:33:13 +0000 (16:33 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sat, 27 May 2017 18:09:06 +0000 (14:09 -0400)
$ time ./converter/babeltrace --plugin-path=plugins ~/lttng-traces/allo-20160829-153459/kernel/ > /dev/null

real    0m6.490s
user    0m6.413s
sys     0m0.067s

Caching of event class id and name

$ time ./converter/babeltrace --plugin-path=plugins ~/lttng-traces/allo-20160829-153459/kernel/ > /dev/null

real    0m1.027s
user    0m1.013s
sys     0m0.003s

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
formats/ctf/ir/event-class.c
include/babeltrace/ctf-ir/event-class-internal.h

index 750203aeef24b3e85e042b1bed63a21235c50a6b..fa55457c3cb15dd1fefba7dc9f43f6ae312d1ef0 100644 (file)
@@ -58,6 +58,7 @@ struct bt_ctf_event_class *bt_ctf_event_class_create(const char *name)
                goto error;
        }
 
+       event_class->id = -1;
        bt_object_init(event_class, bt_ctf_event_class_destroy);
        event_class->fields = bt_ctf_field_type_structure_create();
        if (!event_class->fields) {
@@ -112,6 +113,11 @@ const char *bt_ctf_event_class_get_name(struct bt_ctf_event_class *event_class)
                goto end;
        }
 
+       if (event_class->name) {
+               name = event_class->name;
+               goto end;
+       }
+
        obj = bt_ctf_attributes_get_field_value(event_class->attributes,
                BT_CTF_EVENT_CLASS_ATTR_NAME_INDEX);
        if (!obj) {
@@ -137,6 +143,11 @@ int64_t bt_ctf_event_class_get_id(struct bt_ctf_event_class *event_class)
                goto end;
        }
 
+       if (event_class->id >= 0) {
+               ret = event_class->id;
+               goto end;
+       }
+
        obj = bt_ctf_attributes_get_field_value(event_class->attributes,
                BT_CTF_EVENT_CLASS_ATTR_ID_INDEX);
        if (!obj) {
@@ -547,6 +558,8 @@ void bt_ctf_event_class_freeze(struct bt_ctf_event_class *event_class)
 {
        assert(event_class);
        event_class->frozen = 1;
+       event_class->name = bt_ctf_event_class_get_name(event_class);
+       event_class->id = bt_ctf_event_class_get_id(event_class);
        bt_ctf_field_type_freeze(event_class->context);
        bt_ctf_field_type_freeze(event_class->fields);
        bt_ctf_attributes_freeze(event_class->attributes);
index 1c6a9a6c4e667af8829deeee9b1be1dfce3e10b6..43b6ac41ce05420dcc27b80d1d74e8a01011859f 100644 (file)
@@ -56,6 +56,10 @@ struct bt_ctf_event_class {
         * no events are created out of this event class.
         */
        int valid;
+
+       /* Cached values */
+       const char *name;
+       int64_t id;
 };
 
 BT_HIDDEN
This page took 0.026898 seconds and 4 git commands to generate.