lisa.trace.TxtTraceParser#

class lisa.trace.TxtTraceParser(*args, **kwargs)[source]#

Bases: TxtTraceParserBase

Text trace parser for the raw output of trace-cmd report -R trace.dat.

Parameters:
  • lines (collections.abc.Iterable(str)) – Iterable of text lines.

  • events (list(str) or None) – List of events that will be available using parse_event(). If not provided, all events will be considered. .. note:: Restricting the set of events can speed up some operations.

  • event_parsers (list(EventParserBase)) –

    Pre-built event parsers. Missing event parsers will be inferred from the fields parsed in the trace, which is costly and can lead to using larger dtypes than necessary (e.g. int64 rather than uint16).

    See also

    TxtEventParser

  • default_event_parser_cls – Class used to build event parsers inferred from the trace.

Classes

DEFAULT_EVENT_PARSER_CLS

Trace event parser for raw output of trace-cmd report -R trace.dat.

Attributes

EVENT_DESCS

Mapping of event names to parser description as a dict.

DTYPE_INFERENCE_ORDER inherited

When the dtype of a field is not provided by a user-defined parser, these dtypes will be tried in order to convert the column from string to something more appropriate.

HEADER_FIELDS inherited

Pandas dtype of the header fields.

METADATA_KEYS inherited

Possible metadata keys.

Properties

logger inherited

Convenience short-hand for self.get_logger().

Methods

from_dat()

Build an instance from a path to a trace.dat file created with trace-cmd.

__enter__() inherited

__exit__() inherited

factory() inherited

Decorator to use on alternative constructors, i.e. classmethods that return instances of the class.

from_string() inherited

Build an instance from a single multiline string.

from_txt_file() inherited

Build an instance from a path to a text file.

get_all_metadata() inherited

Collect all available metadata.

get_logger() inherited

Provides a logging.Logger named after cls.

get_metadata() inherited

Return the metadata value.

get_parser_id() inherited

Get the unique ID of that parser. Any parameter affecting the output dataframes or metadata must be somehow part of that ID, so that the cache is not accidentally hit with stale data.

log_locals() inherited

Debugging aid: log the local variables of the calling function.

parse_all_events() inherited

Parse all available events.

parse_event() inherited

Parse the given event from the trace and return a pandas.DataFrame with the following columns:.

parse_events() inherited

Same as parse_event() but taking a list of events as input, and returning a mapping of event names to pandas.DataFrame for each.

Classes#

TxtTraceParser.DEFAULT_EVENT_PARSER_CLS#

alias of TxtEventParser

Attributes#

TxtTraceParser.EVENT_DESCS = {'bprint': <lisa.trace.PrintTxtEventParser object>, 'bputs': <lisa.trace.PrintTxtEventParser object>, 'cpu_frequency': {'fields': {'cpu_id': 'uint16', 'state': 'uint32'}}, 'cpu_idle': {'fields': {'cpu_id': 'uint16', 'state': 'int64'}}, 'cpuhp_enter': {'fields': {'cpu': 'uint16', 'fun': 'string', 'idx': 'uint16', 'target': 'uint16'}}, 'funcgraph_entry': {'fields': {'depth': 'uint16', 'func': 'uint64'}}, 'funcgraph_exit': {'fields': {'calltime': 'uint64', 'depth': 'uint16', 'func': 'uint64', 'overrun': 'bool', 'rettime': 'uint64'}}, 'ipi_entry': {'fields': {'reason': 'string'}, 'positional_field': 'reason', 'raw': False}, 'ipi_exit': {'fields': {'reason': 'string'}, 'positional_field': 'reason', 'raw': False}, 'ipi_raise': <lisa.trace.CustomFieldsTxtEventParser object>, 'lisa__sched_cpu_capacity': {'fields': {'capacity': 'uint16', 'capacity_curr': 'uint16', 'capacity_orig': 'uint16', 'cpu': 'uint16'}}, 'lisa__sched_overutilized': {'fields': {'overutilized': 'bool', 'span': 'string'}}, 'lisa__sched_pelt_cfs': {'fields': {'cpu': 'uint16', 'load': 'uint16', 'path': 'string', 'rbl_load': 'uint16', 'update_time': 'uint64', 'util': 'uint16'}}, 'lisa__sched_pelt_dl': {'fields': {'cpu': 'uint16', 'load': 'uint16', 'rbl_load': 'uint16', 'util': 'uint16'}}, 'lisa__sched_pelt_irq': {'fields': {'cpu': 'uint16', 'load': 'uint16', 'rbl_load': 'uint16', 'util': 'uint16'}}, 'lisa__sched_pelt_rt': {'fields': {'cpu': 'uint16', 'load': 'uint16', 'rbl_load': 'uint16', 'util': 'uint16'}}, 'lisa__sched_pelt_se': {'fields': {'comm': 'string', 'cpu': 'uint16', 'load': 'uint16', 'path': 'string', 'pid': 'int32', 'rbl_load': 'uint16', 'update_time': 'uint64', 'util': 'uint16'}}, 'lisa__sched_util_est_cfs': {'fields': {'cpu': 'uint16', 'enqueued': 'uint16', 'ewma': 'uint16', 'path': 'string', 'util': 'uint16'}}, 'lisa__sched_util_est_se': {'fields': {'comm': 'string', 'cpu': 'uint16', 'enqueued': 'uint16', 'ewma': 'uint16', 'path': 'string', 'pid': 'int32', 'util': 'uint16'}}, 'lisa__uclamp_util_cfs': {'fields': {'cpu': 'uint16', 'uclamp_avg': 'uint16', 'uclamp_max': 'uint16', 'uclamp_min': 'uint16', 'util_avg': 'uint16'}}, 'lisa__uclamp_util_se': {'fields': {'comm': 'string', 'cpu': 'uint16', 'pid': 'uint32', 'uclamp_avg': 'uint16', 'uclamp_max': 'uint16', 'uclamp_min': 'uint16', 'util_avg': 'uint16'}}, 'print': <lisa.trace.PrintTxtEventParser object>, 'sched_compute_energy': {'fields': {'comm': 'string', 'dst_cpu': 'uint16', 'energy': 'uint64', 'pid': 'uint32', 'prev_cpu': 'uint16'}}, 'sched_migrate_task': {'fields': {'comm': 'string', 'dest_cpu': 'uint16', 'orig_cpu': 'uint16', 'pid': 'uint32', 'prio': 'int16'}}, 'sched_process_wait': {'fields': {'comm': 'string', 'pid': 'uint32', 'prio': 'int16'}}, 'sched_switch': {'fields': {'next_comm': 'string', 'next_pid': 'uint32', 'next_prio': 'int16', 'prev_comm': 'string', 'prev_pid': 'uint32', 'prev_prio': 'int16', 'prev_state': 'uint16'}}, 'sched_wakeup': {'fields': {'comm': 'string', 'pid': 'uint32', 'prio': 'int16', 'target_cpu': 'uint16'}}, 'sched_wakeup_new': {'fields': {'comm': 'string', 'pid': 'uint32', 'prio': 'int16', 'success': 'bool', 'target_cpu': 'uint16'}}, 'sched_waking': {'fields': {'comm': 'string', 'pid': 'uint32', 'prio': 'int16', 'success': 'bool', 'target_cpu': 'uint16'}}, 'task_rename': {'fields': {'newcomm': 'string', 'oldcomm': 'string', 'pid': 'uint32'}}, 'thermal_power_cpu_get_power': {'fields': {'cpus': 'bytes', 'dynamic_power': 'uint32', 'freq': 'uint32', 'load': 'bytes'}, 'raw': False}, 'thermal_power_cpu_limit': {'fields': {'cdev_state': 'uint64', 'cpus': 'bytes', 'freq': 'uint32', 'power': 'uint32'}, 'raw': False}}#

Mapping of event names to parser description as a dict.

Each event description can include the constructor parameters of the class used as DEFAULT_EVENT_PARSER_CLS, which will be used to build event parsers from the descriptions.

If an instance of EventParserBase is passed instead of a dict, it will be used as is.

TxtTraceParser.DTYPE_INFERENCE_ORDER = ['int64', 'uint64', 'float64']#

Inherited attribute, see lisa.trace.TxtTraceParserBase.DTYPE_INFERENCE_ORDER

When the dtype of a field is not provided by a user-defined parser, these dtypes will be tried in order to convert the column from string to something more appropriate.

TxtTraceParser.HEADER_FIELDS = {'__comm': 'string', '__cpu': 'uint32', '__event': 'string', '__pid': 'uint32', '__timestamp': 'float64'}#

Inherited attribute, see lisa.trace.TxtTraceParserBase.HEADER_FIELDS

Pandas dtype of the header fields.

TxtTraceParser.METADATA_KEYS = ['time-range', 'symbols-address', 'cpus-count', 'available-events', 'trace-id']#

Inherited attribute, see lisa.trace.TraceParserBase.METADATA_KEYS

Possible metadata keys.

Properties#

property TxtTraceParser.logger#

Inherited property, see lisa.utils.Loggable.logger

Convenience short-hand for self.get_logger().

Methods#

classmethod TxtTraceParser.from_dat(path, events, needed_metadata=None, event_parsers=None, default_event_parser_cls=None, *, pre_filled_metadata=None, temp_dir)[source]#

Build an instance from a path to a trace.dat file created with trace-cmd.

Variable keyword arguments:

Forwarded to __init__

Note

We unfortunately cannot use -F filter option to pre-filter on some events, since global timestamp deduplication has to happen. The returned dataframe must be stable, because it could be reused in another context (cached on disk), and the set of events in a Trace object can be expanded dynamically.

TxtTraceParser.__enter__()#

Inherited method, see lisa.trace.TraceParserBase.__enter__()

TxtTraceParser.__exit__(*args, **kwargs)#

Inherited method, see lisa.trace.TraceParserBase.__exit__()

classmethod TxtTraceParser.factory(f)#

Inherited method, see lisa.utils.PartialInit.factory()

Decorator to use on alternative constructors, i.e. classmethods that return instances of the class.

classmethod TxtTraceParser.from_string(txt, path=None, *, events=None, needed_metadata=None, event_parsers=None, default_event_parser_cls=None, pre_filled_metadata=None, temp_dir)#

Inherited method, see lisa.trace.TxtTraceParserBase.from_string()

Build an instance from a single multiline string.

classmethod TxtTraceParser.from_txt_file(path, *, events=None, needed_metadata=None, event_parsers=None, default_event_parser_cls=None, pre_filled_metadata=None, temp_dir)#

Inherited method, see lisa.trace.TxtTraceParserBase.from_txt_file()

Build an instance from a path to a text file.

TxtTraceParser.get_all_metadata()#

Inherited method, see lisa.trace.TraceParserBase.get_all_metadata()

Collect all available metadata.

classmethod TxtTraceParser.get_logger(suffix=None)#

Inherited method, see lisa.utils.Loggable.get_logger()

Provides a logging.Logger named after cls.

TxtTraceParser.get_metadata(key)#

Inherited method, see lisa.trace.TxtTraceParserBase.get_metadata()

Return the metadata value.

TxtTraceParser.get_parser_id()#

Inherited method, see lisa.trace.TraceParserBase.get_parser_id()

Get the unique ID of that parser. Any parameter affecting the output dataframes or metadata must be somehow part of that ID, so that the cache is not accidentally hit with stale data.

classmethod TxtTraceParser.log_locals(var_names=None, level='debug')#

Inherited method, see lisa.utils.Loggable.log_locals()

Debugging aid: log the local variables of the calling function.

TxtTraceParser.parse_all_events()#

Inherited method, see lisa.trace.TraceParserBase.parse_all_events()

Parse all available events.

TxtTraceParser.parse_event(event)#

Inherited method, see lisa.trace.TxtTraceParserBase.parse_event()

Parse the given event from the trace and return a pandas.DataFrame with the following columns:.

TxtTraceParser.parse_events(events, best_effort=False, **kwargs)#

Inherited method, see lisa.trace.TraceParserBase.parse_events()

Same as parse_event() but taking a list of events as input, and returning a mapping of event names to pandas.DataFrame for each.