Skip to content

Commit

Permalink
instruments/trace_cmd: Add tracing mode support to TraceCmdInstrument()
Browse files Browse the repository at this point in the history
Implement tracing mode support (mainly for write-to-disk mode) in
TraceCmdInstrument, enabling efficient collection of large trace
datasets without encountering memory limitations.

This feature is particularly useful for scenarios requiring extensive
trace data.

Additional changes:
- Replace hardcoded strings with corresponding string literals for
  improved maintainability.

Signed-off-by: Metin Kaya <metin.kaya@arm.com>
  • Loading branch information
metin-arm committed Jan 29, 2025
1 parent 45f09a6 commit 7952451
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions doc/source/user_information/user_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ below:
no_install: false
report: true
report_on_target: false
mode: write-to-memory
csv:
extra_columns: null
use_all_classifiers: false
Expand Down
1 change: 1 addition & 0 deletions doc/source/user_information/user_reference/agenda.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ An example agenda can be seen here:
no_install: false
report: true
report_on_target: false
mode: write-to-disk
csv: # Provide config for the csv augmentation
use_all_classifiers: true
Expand Down
13 changes: 11 additions & 2 deletions wa/instruments/trace_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@ class TraceCmdInstrument(Instrument):
installed on the host (the one in your
distribution's repos may be too old).
"""),
Parameter('mode', kind=str, default='write-to-memory',
description="""
Specifies whether collected traces should be saved in memory or disk.
Extensive workloads may hit out of memory issue. Hence, write-to-disk
mode can help in such cases.
"""),
]

def __init__(self, target, **kwargs):
Expand All @@ -183,6 +189,7 @@ def initialize(self, context):
no_install=self.no_install,
strict=False,
report_on_target=False,
mode=self.mode,
)
if self.report and self.report_on_target:
collector_params['autoreport'] = True
Expand Down Expand Up @@ -215,12 +222,14 @@ def update_output(self, context): # NOQA pylint: disable=R0912
if not self.collector:
return
self.logger.info('Extracting trace from target...')
outfile = os.path.join(context.output_directory, 'trace.dat')
outfile = os.path.join(context.output_directory, OUTPUT_TRACE_FILE)

self.collector.set_output(outfile)
self.collector.get_data()
context.add_artifact('trace-cmd-bin', outfile, 'data')
if self.report:
textfile = os.path.join(context.output_directory, 'trace.txt')
textfile = os.path.join(context.output_directory, OUTPUT_TEXT_FILE)

if not self.report_on_target:
self.collector.report(outfile, textfile)
context.add_artifact('trace-cmd-txt', textfile, 'export')
Expand Down

0 comments on commit 7952451

Please sign in to comment.