aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSeongJae Park <sj38.park@gmail.com>2024-03-31 10:00:27 -0700
committerSeongJae Park <sj38.park@gmail.com>2024-03-31 10:01:30 -0700
commit3978df3415859da3d2cd2e30976088d67759b317 (patch)
tree46a532022dc4be54e2709b9de289dfa7b1d48544
parent164d1e6b67f962c9a2c8d4a6c23645f5d8a23b6a (diff)
downloaddamo-3978df3415859da3d2cd2e30976088d67759b317.tar.gz
damo_record: Add option for memory footprint recording
Add an option --footprint for memory footprint recording. If the option is given, 'damo record' records 'statm' content of all target processes in a json file (name is same to the damon reocrd, but has '.mem_footprint' suffix. Signed-off-by: SeongJae Park <sj38.park@gmail.com>
-rw-r--r--damo_record.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/damo_record.py b/damo_record.py
index 5949631a..89a09e46 100644
--- a/damo_record.py
+++ b/damo_record.py
@@ -4,6 +4,7 @@
Record monitored data access patterns.
"""
+import json
import os
import signal
import subprocess
@@ -136,6 +137,20 @@ def poll_target_pids(kdamonds, add_childs):
cleanup_exit(1)
return True
+def record_mem_footprint(kdamonds, snapshots):
+ pids = []
+ for kdamond in kdamonds:
+ for ctx in kdamond.contexts:
+ for target in ctx.targets:
+ if target.pid is None:
+ continue
+ pids.append(target.pid)
+ snapshots.append(MemFootprintsSnapshot(pids))
+
+def save_mem_footprint(snapshots, filepath):
+ with open(filepath, 'w') as f:
+ json.dump([s.to_kvpairs() for s in snapshots], f, indent=4)
+
def main(args):
global data_for_cleanup
@@ -181,10 +196,16 @@ def main(args):
profile=args.profile is True, profile_target_pid=None)
print('Press Ctrl+C to stop')
+ footprint_snapshots = []
if _damon_args.self_started_target(args):
while poll_target_pids(kdamonds, args.include_child_tasks):
+ if args.footprint:
+ record_mem_footprint(kdamonds, footprint_snapshots)
time.sleep(1)
+ if args.footprint:
+ save_mem_footprint(footprint_snapshots, '%s.mem_footprint' % args.out)
+
_damon.wait_kdamonds_turned_off()
cleanup_exit(0)
@@ -205,5 +226,7 @@ def set_argparser(parser):
help='record schemes tried to be applied regions')
parser.add_argument('--profile', action='store_true',
help='record profiling information together')
+ parser.add_argument('--footprint', action='store_true',
+ help='record memory footprint (VSZ and RSS)')
parser.description = 'Record monitoring results'
return parser