diff options
author | SeongJae Park <sj38.park@gmail.com> | 2024-04-06 09:32:09 -0700 |
---|---|---|
committer | SeongJae Park <sj38.park@gmail.com> | 2024-04-06 09:32:09 -0700 |
commit | 3f357ec5a75354d2ae9d590745dfcba2120f855c (patch) | |
tree | 363846b994fa38f6345fda3007a138ecd921e3cb | |
parent | 2995b90ccd699c5565144798dbda4f359a038dce (diff) | |
download | damo-3f357ec5a75354d2ae9d590745dfcba2120f855c.tar.gz |
Rename _damon_records to _damo_records
damo now supports not only DAMON records but also profile and memory
footprint records. _damon_records is handling DAMON records and profile
records. Memory footprint records is handled by damo_record.py, but
would better to move that to _damon_records. Rename _damon_records to
_damo_records for that.
Signed-off-by: SeongJae Park <sj38.park@gmail.com>
-rw-r--r-- | _damo_records.py (renamed from _damon_records.py) | 0 | ||||
-rw-r--r-- | damo_adjust.py | 14 | ||||
-rw-r--r-- | damo_convert_record_format.py | 10 | ||||
-rw-r--r-- | damo_heats.py | 4 | ||||
-rw-r--r-- | damo_nr_regions.py | 4 | ||||
-rw-r--r-- | damo_record.py | 18 | ||||
-rw-r--r-- | damo_record_info.py | 4 | ||||
-rw-r--r-- | damo_replay.py | 4 | ||||
-rw-r--r-- | damo_report_profile.py | 8 | ||||
-rw-r--r-- | damo_report_raw.py | 4 | ||||
-rw-r--r-- | damo_report_times.py | 8 | ||||
-rw-r--r-- | damo_show.py | 8 | ||||
-rw-r--r-- | damo_validate.py | 4 | ||||
-rw-r--r-- | damo_wss.py | 6 | ||||
-rw-r--r-- | tests/unit/test_damo_records.py (renamed from tests/unit/test_damon_records.py) | 34 | ||||
-rw-r--r-- | tests/unit/test_damo_show.py | 6 |
16 files changed, 68 insertions, 68 deletions
diff --git a/_damon_records.py b/_damo_records.py index 8c49be69..8c49be69 100644 --- a/_damon_records.py +++ b/_damo_records.py diff --git a/damo_adjust.py b/damo_adjust.py index 28732931..57c6e90e 100644 --- a/damo_adjust.py +++ b/damo_adjust.py @@ -4,28 +4,28 @@ import argparse -import _damon_records +import _damo_records def main(args): file_path = args.input - output_permission, err = _damon_records.parse_file_permission_str( + output_permission, err = _damo_records.parse_file_permission_str( args.output_permission) if err != None: print('wrong --output_permission (%s) (%s)' % (args.output_permission, err)) exit(1) - records, err = _damon_records.get_records(record_file=file_path) + records, err = _damo_records.get_records(record_file=file_path) if err: print('monitoring result file (%s) parsing failed (%s)' % (file_path, err)) exit(1) if args.aggregate_interval != None: - _damon_records.adjust_records(records, args.aggregate_interval, + _damo_records.adjust_records(records, args.aggregate_interval, args.skip) - err = _damon_records.write_damon_records(records, args.output, + err = _damo_records.write_damon_records(records, args.output, args.output_type, output_permission) if err != None: print('writing adjusted result failed (%s)' % err) @@ -39,8 +39,8 @@ def set_argparser(parser): parser.add_argument('--output', '-o', type=str, metavar='<file>', default='damon.adjusted.data', help='output file name') parser.add_argument('--output_type', - choices=_damon_records.self_write_supported_file_types, - default=_damon_records.file_type_json_compressed, + choices=_damo_records.self_write_supported_file_types, + default=_damo_records.file_type_json_compressed, help='output file\'s type') parser.add_argument('--output_permission', type=str, default='600', help='permission of the output file') diff --git a/damo_convert_record_format.py b/damo_convert_record_format.py index 26696c53..95a6895d 100644 --- a/damo_convert_record_format.py +++ b/damo_convert_record_format.py @@ -2,7 +2,7 @@ import os -import _damon_records +import _damo_records def main(args): if not os.path.isfile(args.record_file): @@ -12,12 +12,12 @@ def main(args): if not args.output_file: args.output_file = args.record_file - records, err = _damon_records.get_records(record_file=args.record_file) + records, err = _damo_records.get_records(record_file=args.record_file) if err != None: print('parsing record file failed (%s)' % err) exit(1) - err = _damon_records.write_damon_records(records, args.output_file, + err = _damo_records.write_damon_records(records, args.output_file, args.format) if err != None: print('writing records again failed (%s)' % err) @@ -27,8 +27,8 @@ def set_argparser(parser): parser.add_argument('--record_file', metavar='<file>', default='damon.data', help='the record file') parser.add_argument('--format', - choices=_damon_records.self_write_supported_file_types, - default=_damon_records.file_type_json_compressed, + choices=_damo_records.self_write_supported_file_types, + default=_damo_records.file_type_json_compressed, help='new file format') parser.add_argument('--output_file', metavar='<file>', help='the path to converted file') diff --git a/damo_heats.py b/damo_heats.py index c2006574..5280cb50 100644 --- a/damo_heats.py +++ b/damo_heats.py @@ -29,7 +29,7 @@ import damo_record_info import _damo_ascii_color import _damo_fmt_str -import _damon_records +import _damo_records class HeatPixel: time = None @@ -292,7 +292,7 @@ def main(args=None): if args.ascii_color == None and args.stdout_heatmap_color == None: args.stdout_heatmap_color = 'gray' - records, err = _damon_records.get_records(record_file=args.input) + records, err = _damo_records.get_records(record_file=args.input) if err != None: print('monitoring result file (%s) parsing failed (%s)' % (args.input, err)) diff --git a/damo_nr_regions.py b/damo_nr_regions.py index 4ebf2be4..71083bb9 100644 --- a/damo_nr_regions.py +++ b/damo_nr_regions.py @@ -7,7 +7,7 @@ import sys import tempfile import _damo_dist -import _damon_records +import _damo_records def set_argparser(parser): parser.add_argument('--input', '-i', type=str, metavar='<file>', @@ -30,7 +30,7 @@ def main(args): if args.sortby == 'time': nr_regions_sort = False - records, err = _damon_records.get_records(record_file=file_path) + records, err = _damo_records.get_records(record_file=file_path) if err != None: print('monitoring result file (%s) parsing failed (%s)' % (file_path, err)) diff --git a/damo_record.py b/damo_record.py index 7557a5a7..ff1ccac6 100644 --- a/damo_record.py +++ b/damo_record.py @@ -12,7 +12,7 @@ import time import _damon import _damon_args -import _damon_records +import _damo_records class DataForCleanup: kdamonds_idxs = None @@ -42,7 +42,7 @@ def cleanup_exit(exit_code): print('failed restoring previous kdamonds setup (%s)' % err) if data_for_cleanup.record_handle: - _damon_records.finish_recording(data_for_cleanup.record_handle) + _damo_records.finish_recording(data_for_cleanup.record_handle) if data_for_cleanup.footprint_snapshots is not None: save_mem_footprint( @@ -60,7 +60,7 @@ def handle_args(args): if _damon.any_kdamond_running() and not args.deducible_target: args.deducible_target = 'ongoing' - args.output_permission, err = _damon_records.parse_file_permission_str( + args.output_permission, err = _damo_records.parse_file_permission_str( args.output_permission) if err != None: print('wrong --output permission (%s) (%s)' % @@ -76,7 +76,7 @@ def handle_args(args): if os.path.isfile(footprint_file_path): os.rename(footprint_file_path, footprint_file_path + '.old') - err = _damon_records.set_perf_path(args.perf_path) + err = _damo_records.set_perf_path(args.perf_path) if err != None: print(err) exit(-3) @@ -242,11 +242,11 @@ def main(args): 0].contexts[0].intervals if args.schemes_target_regions == False: - tracepoint = _damon_records.perf_event_damon_aggregated + tracepoint = _damo_records.perf_event_damon_aggregated else: - tracepoint = _damon_records.perf_event_damos_before_apply + tracepoint = _damo_records.perf_event_damos_before_apply - data_for_cleanup.record_handle = _damon_records.start_recording( + data_for_cleanup.record_handle = _damo_records.start_recording( tracepoint, args.out, args.output_type, args.output_permission, monitoring_intervals, profile=args.profile is True, profile_target_pid=None) @@ -268,8 +268,8 @@ def main(args): def set_argparser(parser): parser = _damon_args.set_argparser(parser, add_record_options=True) parser.add_argument('--output_type', - choices=_damon_records.file_types, - default=_damon_records.file_type_json_compressed, + choices=_damo_records.file_types, + default=_damo_records.file_type_json_compressed, help='output file\'s type') parser.add_argument('--output_permission', type=str, default='600', help='permission of the output file') diff --git a/damo_record_info.py b/damo_record_info.py index 85473025..47812a9e 100644 --- a/damo_record_info.py +++ b/damo_record_info.py @@ -7,7 +7,7 @@ Print basic information of the access monitoring results record file. import argparse import _damo_fmt_str -import _damon_records +import _damo_records class GuideInfo: tid = None @@ -116,7 +116,7 @@ def pr_guide(records): print(guide) def main(args): - records, err = _damon_records.get_records(record_file=args.input) + records, err = _damo_records.get_records(record_file=args.input) if err != None: print('monitoring result file (%s) parsing failed (%s)' % (args.input, err)) diff --git a/damo_replay.py b/damo_replay.py index fb3284f1..d7783d27 100644 --- a/damo_replay.py +++ b/damo_replay.py @@ -5,7 +5,7 @@ import random import time import _damo_fmt_str -import _damon_records +import _damo_records import damo_record_info page_map = {} @@ -69,7 +69,7 @@ def main(args): print('input file (%s) not exists' % input_file) exit(1) - records, err = _damon_records.get_records(record_file=input_file) + records, err = _damo_records.get_records(record_file=input_file) if err: print('parsing damon records file (%s) failed (%s)' % (input_file, err)) diff --git a/damo_report_profile.py b/damo_report_profile.py index 0d5bceb3..254e11d1 100644 --- a/damo_report_profile.py +++ b/damo_report_profile.py @@ -4,16 +4,16 @@ import argparse import subprocess import _damon -import _damon_records +import _damo_records import damo_show def main(args): - record_filter, err = _damon_records.args_to_filter(args) + record_filter, err = _damo_records.args_to_filter(args) if err != None: print(err) exit(1) - records, err = _damon_records.get_records( + records, err = _damo_records.get_records( tried_regions_of=False, record_file=args.inputs[0], record_filter=record_filter, total_sz_only=False, dont_merge_regions=False) @@ -48,6 +48,6 @@ def set_argparser(parser): parser.add_argument('--inputs', metavar='<file>', nargs=2, default=['damon.data', 'damon.data.profile'], help='access pattern and profile record files') - _damon_records.set_filter_argparser(parser) + _damo_records.set_filter_argparser(parser) parser.description='Show profiling report for specific access pattern' diff --git a/damo_report_raw.py b/damo_report_raw.py index d5e8107e..8c999395 100644 --- a/damo_report_raw.py +++ b/damo_report_raw.py @@ -7,7 +7,7 @@ import sys import _damo_fmt_str import _damo_print -import _damon_records +import _damo_records def filter_snapshots(records, start_time_sec, end_time_sec): for record in records: @@ -88,7 +88,7 @@ def main(args): print('input file (%s) is not exist' % file_path) exit(1) - records, err = _damon_records.get_records(record_file=file_path) + records, err = _damo_records.get_records(record_file=file_path) if err: print('parsing damon result file (%s) failed (%s)' % (file_path, err)) diff --git a/damo_report_times.py b/damo_report_times.py index 1756a364..3145c497 100644 --- a/damo_report_times.py +++ b/damo_report_times.py @@ -4,16 +4,16 @@ import argparse import subprocess import _damon -import _damon_records +import _damo_records import damo_show def main(args): - record_filter, err = _damon_records.args_to_filter(args) + record_filter, err = _damo_records.args_to_filter(args) if err != None: print(err) exit(1) - records, err = _damon_records.get_records( + records, err = _damo_records.get_records( tried_regions_of=False, record_file=args.inputs[0], record_filter=record_filter, total_sz_only=False, dont_merge_regions=False) @@ -42,6 +42,6 @@ def set_argparser(parser): parser.add_argument('--inputs', metavar='<file>', nargs=2, default=['damon.data', 'damon.data.profile'], help='access pattern and profile record files') - _damon_records.set_filter_argparser(parser) + _damo_records.set_filter_argparser(parser) parser.description='Show times of record having specific access pattern' diff --git a/damo_show.py b/damo_show.py index 5a5d4e53..f4069798 100644 --- a/damo_show.py +++ b/damo_show.py @@ -9,7 +9,7 @@ import _damo_fmt_str import _damo_print import _damon import _damon_args -import _damon_records +import _damo_records class Formatter: keyword = None @@ -525,7 +525,7 @@ def main(args): args.region_box_values = [v if v != 'none' else None for v in args.region_box_values] - record_filter, err = _damon_records.args_to_filter(args) + record_filter, err = _damo_records.args_to_filter(args) if err != None: print(err) exit(1) @@ -533,7 +533,7 @@ def main(args): if args.input_file == None: _damon.ensure_root_and_initialized(args, load_feature_supports=True) - records, err = _damon_records.get_records( + records, err = _damo_records.get_records( tried_regions_of=args.tried_regions_of, record_file=args.input_file, record_filter=record_filter, total_sz_only=args.total_sz_only, @@ -557,7 +557,7 @@ def set_argparser(parser): _damon_args.set_common_argparser(parser) # what to show - _damon_records.set_filter_argparser(parser) + _damo_records.set_filter_argparser(parser) parser.add_argument('--input_file', metavar='<file>', help='source of the access pattern to show') diff --git a/damo_validate.py b/damo_validate.py index 652d8ded..b234425f 100644 --- a/damo_validate.py +++ b/damo_validate.py @@ -5,7 +5,7 @@ import argparse import os -import _damon_records +import _damo_records def assert_value_in_range(value, min_max, name, error_allowed): '''Returns 0 if the value is in the range, 1 if the value is out of range @@ -45,7 +45,7 @@ def main(args): print('wrong boundary input %s' % boundary) regions_boundary.append(parsed_boundary) - records, err = _damon_records.get_records(record_file=args.input) + records, err = _damo_records.get_records(record_file=args.input) if err != None: print('parsing failed (%s)' % err) exit(1) diff --git a/damo_wss.py b/damo_wss.py index 5cfb410b..9d56fa92 100644 --- a/damo_wss.py +++ b/damo_wss.py @@ -8,7 +8,7 @@ import tempfile import _damo_dist import _damo_fmt_str -import _damon_records +import _damo_records def get_wss_dists(records, acc_thres, sz_thres, do_sort): wss_dists = {} @@ -110,13 +110,13 @@ def main(args): wss_sort = False raw_number = args.raw_number - records, err = _damon_records.get_records(record_file=file_path) + records, err = _damo_records.get_records(record_file=file_path) if err != None: print('monitoring result file (%s) parsing failed (%s)' % (file_path, err)) exit(1) - _damon_records.adjust_records(records, args.work_time, args.exclude_samples) + _damo_records.adjust_records(records, args.work_time, args.exclude_samples) wss_dists = get_wss_dists(records, args.acc_thres, args.sz_thres, wss_sort) if args.plot: diff --git a/tests/unit/test_damon_records.py b/tests/unit/test_damo_records.py index 0b77635e..65a35090 100644 --- a/tests/unit/test_damon_records.py +++ b/tests/unit/test_damo_records.py @@ -8,28 +8,28 @@ import _test_damo_common _test_damo_common.add_damo_dir_to_syspath() import _damon -import _damon_records +import _damo_records class TestDamon(unittest.TestCase): def test_parse_file_permission_str(self): - perm, err = _damon_records.parse_file_permission_str('777') + perm, err = _damo_records.parse_file_permission_str('777') self.assertEqual(perm, 0o777) self.assertIsNone(err) - perm, err = _damon_records.parse_file_permission_str('-123') + perm, err = _damo_records.parse_file_permission_str('-123') self.assertIsNone(perm) self.assertIsNotNone(err) - perm, err = _damon_records.parse_file_permission_str('1000') + perm, err = _damo_records.parse_file_permission_str('1000') self.assertIsNone(perm) self.assertIsNotNone(err) - perm, err = _damon_records.parse_file_permission_str('778') + perm, err = _damo_records.parse_file_permission_str('778') self.assertIsNone(perm) self.assertIsNotNone(err) def test_record_from_kvpairs(self): - records = [_damon_records.DamonRecord.from_kvpairs(p) for p in [ + records = [_damo_records.DamonRecord.from_kvpairs(p) for p in [ { "kdamond_idx": 0, "context_idx": 0, "intervals": { @@ -65,7 +65,7 @@ class TestDamon(unittest.TestCase): # test DamonSnapshot.total_bytes added by commit 98c1bd8f467f6. Test # older output that doesn't have the data. - records = [_damon_records.DamonRecord.from_kvpairs(p) for p in [ + records = [_damo_records.DamonRecord.from_kvpairs(p) for p in [ { "kdamond_idx": 0, "context_idx": 0, "intervals": { @@ -102,37 +102,37 @@ class TestDamon(unittest.TestCase): ranges = [[3, 5], [6, 9], [10, 12]] region = _damon.DamonRegion(7, 8) self.assertEqual( - _damon_records.filter_by_addr(_damon.DamonRegion(7, 8), + _damo_records.filter_by_addr(_damon.DamonRegion(7, 8), ranges), [_damon.DamonRegion(7, 8)]) self.assertEqual( - _damon_records.filter_by_addr(_damon.DamonRegion(1, 2), + _damo_records.filter_by_addr(_damon.DamonRegion(1, 2), ranges), []) self.assertEqual( - _damon_records.filter_by_addr(_damon.DamonRegion(5, 6), + _damo_records.filter_by_addr(_damon.DamonRegion(5, 6), ranges), []) self.assertEqual( - _damon_records.filter_by_addr(_damon.DamonRegion(1, 4), + _damo_records.filter_by_addr(_damon.DamonRegion(1, 4), ranges), [_damon.DamonRegion(3, 4)]) self.assertEqual( - _damon_records.filter_by_addr(_damon.DamonRegion(1, 20), + _damo_records.filter_by_addr(_damon.DamonRegion(1, 20), ranges), [_damon.DamonRegion(3, 5), _damon.DamonRegion(6, 9), _damon.DamonRegion(10, 12)]) def test_parse_sort_bytes_ranges_input(self): self.assertEqual( - _damon_records.parse_sort_bytes_ranges_input([['1G', '2G']]), + _damo_records.parse_sort_bytes_ranges_input([['1G', '2G']]), ([[1024 * 1024 * 1024, 1024 * 1024 * 1024 * 2]], None)) - ranges, err = _damon_records.parse_sort_bytes_ranges_input( + ranges, err = _damo_records.parse_sort_bytes_ranges_input( [['abc', 'def']]) self.assertNotEqual(err, None) - ranges, err = _damon_records.parse_sort_bytes_ranges_input([[4, 3]]) + ranges, err = _damo_records.parse_sort_bytes_ranges_input([[4, 3]]) self.assertNotEqual(err, None) - ranges, err = _damon_records.parse_sort_bytes_ranges_input( + ranges, err = _damo_records.parse_sort_bytes_ranges_input( [[5, 7], [2, 6]]) self.assertEqual(err, 'overlapping range') self.assertEqual( - _damon_records.parse_sort_bytes_ranges_input( + _damo_records.parse_sort_bytes_ranges_input( [[10, 20], [5, 7]]), ([[5, 7], [10, 20]], None)) if __name__ == '__main__': diff --git a/tests/unit/test_damo_show.py b/tests/unit/test_damo_show.py index 13537e81..a26d67d3 100644 --- a/tests/unit/test_damo_show.py +++ b/tests/unit/test_damo_show.py @@ -8,12 +8,12 @@ import _test_damo_common _test_damo_common.add_damo_dir_to_syspath() import _damon -import _damon_records +import _damo_records import damo_show class TestDamoShow(unittest.TestCase): def test_sorted_access_pattern(self): - record = _damon_records.DamonRecord.from_kvpairs( + record = _damo_records.DamonRecord.from_kvpairs( { "kdamond_idx": 0, "context_idx": 0, "intervals": { @@ -67,7 +67,7 @@ class TestDamoShow(unittest.TestCase): self.assertEqual(sorted_vals.ages_us[-1], 3000000) def test_format_template(self): - record = _damon_records.DamonRecord.from_kvpairs( + record = _damo_records.DamonRecord.from_kvpairs( { "kdamond_idx": 0, "context_idx": 0, "intervals": { |