public
Last active

  • Download Gist
parse_vmtouch.py
Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
#! /usr/bin/env python
import fileinput
import argparse
from operator import itemgetter
 
parser = argparse.ArgumentParser()
parser.add_argument('--target-mb', action = 'store', dest = 'target_mb', default = 61000, type = int)
parser.add_argument('vmtouch_output_file', action = 'store', nargs = '+')
args = parser.parse_args()
 
entries = []
last_fl_name = None
for line in open(args.vmtouch_output_file[0]):
line = line.strip()
if line.startswith('['):
# this is a mem info row
if not last_fl_name:
continue
currently_paged_percent = line.rsplit(' ', 1)[-1]
num, denom = map(float, currently_paged_percent.split('/'))
if num and denom:
bytes = denom * 4096
mb = bytes / (1024 * 1024)
entries.append((last_fl_name, num / denom, mb))
elif line.startswith('.') or line.startswith('/'):
last_fl_name = line
 
sorted_entries = sorted(entries, key = itemgetter(1), reverse = True)
loaded_mb = 0
 
to_page_in = []
for entry in sorted_entries:
if loaded_mb <= args.target_mb:
loaded_mb += entry[-1]
to_page_in.append(entry[0])
 
print 'vmtouch -m 5G -vt', ' '.join(to_page_in)

what command do you use to generate the vmtouch output on one machine ?

I think it's something like: vmtouch -vf > vmtouch_output_file.txt

We do vmtouch -v -m 5G * > output.txt

On Apr 12, 2012, at 6:32 AM, Patrickreply@reply.github.com wrote:

I think it's something like: vmtouch -vf > vmtouch_output_file.txt


Reply to this email directly or view it on GitHub:
https://gist.github.com/1424540

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.