sink.text.pretty: remove field filtering
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 17 Jun 2019 20:12:49 +0000 (16:12 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Sun, 21 Jul 2019 15:39:24 +0000 (11:39 -0400)
Field filtering uses GQuarks internally. Those generate g hash table
lookups, which appear at the top of perf reports.

This field filtering mechanism is not needed anymore, so remove it.

It's not needed anymore because the packet context fields and the event
fields are not special or associated to CTF anymore as the library's
trace IR is CTF-agnostic. So those special fields do not exist anyway in
the messages this sink consumes.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I7bf0238e6692fb277dafc32f864b0e20e89bf3d2
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1505
CI-Build: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
src/plugins/text/pretty/pretty.c
src/plugins/text/pretty/pretty.h
src/plugins/text/pretty/print.c

index 48c7a9a002d6fc4066d2c668c4dfc69f618bcc48..5c0aae8209ab8ab487dba183ccc217f515c94663 100644 (file)
@@ -34,8 +34,6 @@
 
 #include "pretty.h"
 
-GQuark stream_packet_context_quarks[STREAM_PACKET_CONTEXT_QUARKS_LEN];
-
 static
 const char *plugin_options[] = {
        "color",
@@ -609,25 +607,6 @@ void set_use_colors(struct pretty_component *pretty)
        }
 }
 
-static
-void init_stream_packet_context_quarks(void)
-{
-       stream_packet_context_quarks[Q_TIMESTAMP_BEGIN] =
-               g_quark_from_string("timestamp_begin");
-       stream_packet_context_quarks[Q_TIMESTAMP_BEGIN] =
-               g_quark_from_string("timestamp_begin");
-       stream_packet_context_quarks[Q_TIMESTAMP_END] =
-               g_quark_from_string("timestamp_end");
-       stream_packet_context_quarks[Q_EVENTS_DISCARDED] =
-               g_quark_from_string("events_discarded");
-       stream_packet_context_quarks[Q_CONTENT_SIZE] =
-               g_quark_from_string("content_size");
-       stream_packet_context_quarks[Q_PACKET_SIZE] =
-               g_quark_from_string("packet_size");
-       stream_packet_context_quarks[Q_PACKET_SEQ_NUM] =
-               g_quark_from_string("packet_seq_num");
-}
-
 BT_HIDDEN
 bt_component_class_init_method_status pretty_init(
                bt_self_component_sink *comp, const bt_value *params,
@@ -665,7 +644,6 @@ bt_component_class_init_method_status pretty_init(
        set_use_colors(pretty);
        bt_self_component_set_data(
                bt_self_component_sink_as_self_component(comp), pretty);
-       init_stream_packet_context_quarks();
 
 end:
        return ret;
index f038643a17e3df4f373591344a1c5e0274f071e0..cffe7ca7d237ee4ea28c3458c2d59e995ab0b7a5 100644 (file)
@@ -92,19 +92,6 @@ struct pretty_component {
        bool negative_timestamp_warning_done;
 };
 
-enum stream_packet_context_quarks_enum {
-       Q_TIMESTAMP_BEGIN,
-       Q_TIMESTAMP_END,
-       Q_EVENTS_DISCARDED,
-       Q_CONTENT_SIZE,
-       Q_PACKET_SIZE,
-       Q_PACKET_SEQ_NUM,
-       STREAM_PACKET_CONTEXT_QUARKS_LEN, /* Always the last one of this enum. */
-};
-
-extern
-GQuark stream_packet_context_quarks[STREAM_PACKET_CONTEXT_QUARKS_LEN];
-
 BT_HIDDEN
 bt_component_class_init_method_status pretty_init(
                bt_self_component_sink *component, const bt_value *params,
index c882e76b58ca6c6c7045026cae31a8d7dacb3586..b3aaeb44d030785c7064daf1114b4b1d686b8f05 100644 (file)
@@ -53,8 +53,7 @@ struct timestamp {
 
 static
 int print_field(struct pretty_component *pretty,
-               const bt_field *field, bool print_names,
-               GQuark *filters_fields, int filter_array_len);
+               const bt_field *field, bool print_names);
 
 static
 void print_name_equal(struct pretty_component *pretty, const char *name)
@@ -749,31 +748,11 @@ end:
        return ret;
 }
 
-static
-int filter_field_name(struct pretty_component *pretty, const char *field_name,
-               GQuark *filter_fields, int filter_array_len)
-{
-       int i;
-       GQuark field_quark = g_quark_try_string(field_name);
-
-       if (!field_quark || pretty->options.verbose) {
-               return 1;
-       }
-
-       for (i = 0; i < filter_array_len; i++) {
-               if (field_quark == filter_fields[i]) {
-                       return 0;
-               }
-       }
-       return 1;
-}
-
 static
 int print_struct_field(struct pretty_component *pretty,
                const bt_field *_struct,
                const bt_field_class *struct_class,
-               uint64_t i, bool print_names, uint64_t *nr_printed_fields,
-               GQuark *filter_fields, int filter_array_len)
+               uint64_t i, bool print_names, uint64_t *nr_printed_fields)
 {
        int ret = 0;
        const char *field_name;
@@ -790,12 +769,6 @@ int print_struct_field(struct pretty_component *pretty,
                struct_class, i);
        field_name = bt_field_class_structure_member_get_name(member);
 
-       if (filter_fields && !filter_field_name(pretty, field_name,
-                               filter_fields, filter_array_len)) {
-               ret = 0;
-               goto end;
-       }
-
        if (*nr_printed_fields > 0) {
                g_string_append(pretty->string, ", ");
        } else {
@@ -804,7 +777,7 @@ int print_struct_field(struct pretty_component *pretty,
        if (print_names) {
                print_field_name_equal(pretty, field_name);
        }
-       ret = print_field(pretty, field, print_names, NULL, 0);
+       ret = print_field(pretty, field, print_names);
        *nr_printed_fields += 1;
 
 end:
@@ -813,8 +786,7 @@ end:
 
 static
 int print_struct(struct pretty_component *pretty,
-               const bt_field *_struct, bool print_names,
-               GQuark *filter_fields, int filter_array_len)
+               const bt_field *_struct, bool print_names)
 {
        int ret = 0;
        const bt_field_class *struct_class = NULL;
@@ -833,8 +805,7 @@ int print_struct(struct pretty_component *pretty,
        nr_printed_fields = 0;
        for (i = 0; i < nr_fields; i++) {
                ret = print_struct_field(pretty, _struct, struct_class, i,
-                               print_names, &nr_printed_fields, filter_fields,
-                               filter_array_len);
+                               print_names, &nr_printed_fields);
                if (ret != 0) {
                        goto end;
                }
@@ -863,7 +834,7 @@ int print_array_field(struct pretty_component *pretty,
 
        field = bt_field_array_borrow_element_field_by_index_const(array, i);
        BT_ASSERT(field);
-       return print_field(pretty, field, print_names, NULL, 0);
+       return print_field(pretty, field, print_names);
 }
 
 static
@@ -913,7 +884,7 @@ int print_sequence_field(struct pretty_component *pretty,
 
        field = bt_field_array_borrow_element_field_by_index_const(seq, i);
        BT_ASSERT(field);
-       return print_field(pretty, field, print_names, NULL, 0);
+       return print_field(pretty, field, print_names);
 }
 
 static
@@ -956,7 +927,7 @@ int print_variant(struct pretty_component *pretty,
                // TODO: find tag's name using field path
                // print_field_name_equal(pretty, tag_choice);
        }
-       ret = print_field(pretty, field, print_names, NULL, 0);
+       ret = print_field(pretty, field, print_names);
        if (ret != 0) {
                goto end;
        }
@@ -969,8 +940,7 @@ end:
 
 static
 int print_field(struct pretty_component *pretty,
-               const bt_field *field, bool print_names,
-               GQuark *filter_fields, int filter_array_len)
+               const bt_field *field, bool print_names)
 {
        bt_field_class_type class_id;
 
@@ -1015,8 +985,7 @@ int print_field(struct pretty_component *pretty,
                return 0;
        }
        case BT_FIELD_CLASS_TYPE_STRUCTURE:
-               return print_struct(pretty, field, print_names, filter_fields,
-                               filter_array_len);
+               return print_struct(pretty, field, print_names);
        case BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR:
        case BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_SELECTOR:
        case BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_SELECTOR:
@@ -1056,9 +1025,7 @@ int print_stream_packet_context(struct pretty_component *pretty,
                print_name_equal(pretty, "stream.packet.context");
        }
        ret = print_field(pretty, main_field,
-                       pretty->options.print_context_field_names,
-                       stream_packet_context_quarks,
-                       STREAM_PACKET_CONTEXT_QUARKS_LEN);
+                       pretty->options.print_context_field_names);
 
 end:
        return ret;
@@ -1083,7 +1050,7 @@ int print_stream_event_context(struct pretty_component *pretty,
                print_name_equal(pretty, "stream.event.context");
        }
        ret = print_field(pretty, main_field,
-                       pretty->options.print_context_field_names, NULL, 0);
+                       pretty->options.print_context_field_names);
 
 end:
        return ret;
@@ -1108,7 +1075,7 @@ int print_event_context(struct pretty_component *pretty,
                print_name_equal(pretty, "event.context");
        }
        ret = print_field(pretty, main_field,
-                       pretty->options.print_context_field_names, NULL, 0);
+                       pretty->options.print_context_field_names);
 
 end:
        return ret;
@@ -1133,7 +1100,7 @@ int print_event_payload(struct pretty_component *pretty,
                print_name_equal(pretty, "event.fields");
        }
        ret = print_field(pretty, main_field,
-                       pretty->options.print_payload_field_names, NULL, 0);
+                       pretty->options.print_payload_field_names);
 
 end:
        return ret;
This page took 0.028711 seconds and 4 git commands to generate.