Skip to contentSkip to conversation

trace-cmd: Optimize pretty_print() function

PATCH New Tzvetomir Stoyanov (VMware) 1 participant 1 message May 29, 2020

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 trace-cmd: Optimize pretty_print() function

Each time the pretty_print() function is called to print an event, the event's format string is parsed. As this format string does not change, this parsing can be done only once - when the event struct is initialized.

---
 include/traceevent/event-parse.h   |   3 +
 lib/traceevent/event-parse-local.h |  17 +
 lib/traceevent/event-parse.c       | 672 ++++++++++++++++++++---------
 3 files changed, 495 insertions(+), 197 deletions(-)
include/traceevent/event-parse.h +3 -0
index cfab6005..9560267f 100644
@@ -259,9 +259,12 @@ struct tep_print_arg {
 	};
 };
 
+struct tep_print_parse;
+
 struct tep_print_fmt {
 	char			*format;
 	struct tep_print_arg	*args;
+	struct tep_print_parse	*print_cache;
 };
 
 struct tep_event {
lib/traceevent/event-parse-local.h +17 -0
index 96a0b0ca..e71296a6 100644
@@ -85,6 +85,23 @@ struct tep_handle {
 	struct tep_plugins_dir *plugins_dir;
 };
 
+enum tep_print_parse_type {
+	PRINT_FMT_STING,
+	PRINT_FMT_ARG_DIGIT,
+	PRINT_FMT_ARG_POINTER,
+	PRINT_FMT_ARG_STRING,
+};
+
+struct tep_print_parse {
+	struct tep_print_parse	*next;
+
+	char				*format;
+	int				ls;
+	enum tep_print_parse_type	type;
+	struct tep_print_arg		*arg;
+	struct tep_print_arg		*len_as_arg;
+};
+
 void tep_free_event(struct tep_event *event);
 void tep_free_format_field(struct tep_format_field *field);
 void tep_free_plugin_paths(struct tep_handle *tep);
lib/traceevent/event-parse.c +475 -197

735 lines not on this page · raw message

Signature · 1 line
2.26.2