Skip to content

Commit f98e105

Browse files
committed
Add RSS status collecting at worker listener
Added to worker listener additional call to RSS status checkin routine to collect it in standalone file. Part of tarantool/tarantool-qa#98
1 parent 920ddc3 commit f98e105

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

listeners.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from lib.utils import safe_makedirs
1616
from lib.utils import print_tail_n
1717
from lib.utils import print_unidiff
18+
from lib.utils import get_mem_stat_rss
1819

1920

2021
class BaseWatcher(object):
@@ -126,6 +127,7 @@ def save_artifacts(self):
126127
class LogOutputWatcher(BaseWatcher):
127128
def __init__(self):
128129
self.fds = dict()
130+
self.fds_stat = dict()
129131
self.logdir = os.path.join(Options().args.vardir, 'log')
130132
try:
131133
os.makedirs(self.logdir)
@@ -137,14 +139,26 @@ def get_logfile(self, worker_name):
137139
filepath = os.path.join(self.logdir, filename)
138140
return os.path.realpath(filepath)
139141

142+
def get_statfile(self, worker_name):
143+
filename = '%s.mem_stat.log' % worker_name
144+
filepath = os.path.join(self.logdir, filename)
145+
return os.path.realpath(filepath)
146+
140147
def process_result(self, obj):
141148
if isinstance(obj, WorkerDone):
142149
self.fds[obj.worker_id].close()
143150
del self.fds[obj.worker_id]
151+
self.fds_stat[obj.worker_id].close()
152+
del self.fds_stat[obj.worker_id]
144153

145154
if not isinstance(obj, WorkerOutput):
146155
return
147156

157+
if obj.worker_id not in self.fds_stat.keys():
158+
filepath = self.get_statfile(obj.worker_name)
159+
self.fds_stat[obj.worker_id] = open(filepath, 'w')
160+
fd_stat = self.fds_stat[obj.worker_id]
161+
148162
if obj.worker_id not in self.fds.keys():
149163
filepath = self.get_logfile(obj.worker_name)
150164
self.fds[obj.worker_id] = open(filepath, 'w')
@@ -169,6 +183,9 @@ def process_result(self, obj):
169183

170184
fd.write(output)
171185
fd.flush()
186+
if (Options().args.collect_statistics):
187+
fd_stat.write(get_mem_stat_rss())
188+
fd_stat.flush()
172189

173190
def __del__(self):
174191
for fd in self.fds.values():

0 commit comments

Comments
 (0)