Skip to content

Commit 6fe257e

Browse files
committed
Add latency logs
1 parent 8e0eab8 commit 6fe257e

File tree

13 files changed

+117
-234
lines changed

13 files changed

+117
-234
lines changed

config/evaluator.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"backend": {
33
"name": "backend",
4-
"log_dir": "/home/vishalr/Desktop/backend-2022/logs/",
5-
"config_dir": "/home/vishalr/Desktop/backend-2022/configs/"
4+
"log_dir": "/home/vishalramesh01/backend-2022/logs/",
5+
"config_dir": "/home/vishalramesh01/backend-2022/configs/"
66
},
77

88
"executor": {
9-
"name": "Assignment2",
10-
"num_backends": 2,
9+
"name": "eval-test",
10+
"num_backends": 1,
1111
"num_workers": 1,
1212
"fetch_port": 9000,
1313
"fetch_route": "get-jobs",
@@ -31,7 +31,7 @@
3131
"docker_port": 10000,
3232
"docker_route": "run_job",
3333
"docker_image": "hadoop-3.2.2:0.1",
34-
"cpu_limit": 6,
34+
"cpu_limit": 2,
3535
"taskset": true,
3636
"memory_limit": "8000m",
3737
"shared_output_dir": "/home/vishalr/Desktop/backend-2022/output/",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[21/04/2023 16:07:38] [output_processor] Team : BD1_ADMIN_09 Assignment ID : A2T1_1682076194 | Wait : 10.2921s Processing : 33.6957s Total: 45.0553s
2+
[21/04/2023 16:08:12] [output_processor] Team : BD1_ADMIN_09 Assignment ID : A2T1_1682075506 | Wait : 41.9155s Processing : 34.4546s Total: 77.3275s
3+
[21/04/2023 16:08:46] [output_processor] Team : BD1_ADMIN_09 Assignment ID : A2T1_1682075079 | Wait : 73.9085s Processing : 34.3627s Total: 109.1788s
4+
[21/04/2023 16:09:20] [output_processor] Team : BD1_ADMIN_09 Assignment ID : A2T1_1682074665 | Wait : 106.4873s Processing : 33.7756s Total: 141.2229s
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[21/04/2023 16:03:13] [output_processor] Team : BD1_ADMIN_09 Assignment ID : A2T1_1682075960 | Wait : 11.2492s Processing : 31.2768s Total: 45.2602s
2+
[21/04/2023 16:03:41] [output_processor] Team : BD1_ADMIN_09 Assignment ID : A2T1_1682081177 | Wait : 37.2587s Processing : 31.4242s Total: 70.8305s
3+
[21/04/2023 16:04:09] [output_processor] Team : BD1_ADMIN_09 Assignment ID : A2T1_1682074946 | Wait : 63.9851s Processing : 29.8131s Total: 96.7524s
4+
[21/04/2023 16:04:37] [output_processor] Team : BD1_ADMIN_09 Assignment ID : A2T1_1682081884 | Wait : 90.8077s Processing : 29.1787s Total: 121.9034s
5+
[21/04/2023 16:05:06] [output_processor] Team : BD1_ADMIN_09 Assignment ID : A2T1_1682079652 | Wait : 111.1782s Processing : 30.1985s Total: 147.2870s

flask_backend/backend.py

+6
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,12 @@ def executor_log():
448448
f.write(logs[logname])
449449
f.close()
450450

451+
logs = json.loads(data["lats_logs"])
452+
for logname in logs:
453+
f = open(os.path.join(executor_log_path, logname), "a+")
454+
f.write(logs[logname])
455+
f.close()
456+
451457
logs = json.loads(data["syslogs"])
452458
for logname in logs:
453459
f = open(os.path.join(executor_log_path, logname), "a+")

job_tracker/executor.py

+16-1
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,16 @@ def get_op_logs(self, path, offset):
296296
logs[filename] = data
297297
return logs, new_offset
298298

299+
def get_lats_logs(self, path, offset):
300+
logs = {}
301+
new_offset = 0
302+
for filename in os.listdir(path):
303+
if ".txt" not in filename or 'lats' not in filename:
304+
continue
305+
data, new_offset = self.read_logs(os.path.join(path, filename), offset)
306+
logs[filename] = data
307+
return logs, new_offset
308+
299309
def get_sys_logs(self, path, offset):
300310
logs = {}
301311
new_offset = 0
@@ -360,17 +370,19 @@ def logs_fn(self):
360370
url = f"http://{self.fetch_ip}:{self.fetch_port}/executor-log"
361371
executor_log_path = os.path.join(self.log_dir, self.executor_name, self.executor_uuid)
362372

363-
wlog_offset, oplog_offset, sys_log_offset = 0, 0, 0
373+
wlog_offset, oplog_offset, latslog_offset, sys_log_offset = 0, 0, 0, 0
364374
while not self.global_queue_thread.stopped():
365375
wlogs, wlog_offset = self.get_worker_logs(executor_log_path, wlog_offset)
366376
oplogs, oplog_offset = self.get_op_logs(executor_log_path, oplog_offset)
377+
latslogs, latslog_offset = self.get_lats_logs(executor_log_path, latslog_offset)
367378
syslogs, sys_log_offset = self.get_sys_logs(executor_log_path, sys_log_offset)
368379

369380
payload = {
370381
'executor_name': self.executor_name,
371382
'executor_uuid': self.executor_uuid,
372383
'worker_logs': json.dumps(wlogs),
373384
'output_processor_logs': json.dumps(oplogs),
385+
'lats_logs': json.dumps(latslogs),
374386
'syslogs': json.dumps(syslogs),
375387
}
376388

@@ -388,12 +400,15 @@ def logs_fn(self):
388400
# send final logs before stopping
389401
wlogs, wlog_offset = self.get_worker_logs(executor_log_path, wlog_offset)
390402
oplogs, oplog_offset = self.get_op_logs(executor_log_path, oplog_offset)
403+
latslogs, latslog_offset = self.get_lats_logs(executor_log_path, latslog_offset)
391404
syslogs, sys_log_offset = self.get_sys_logs(executor_log_path, sys_log_offset)
405+
392406
payload = {
393407
'executor_name': self.executor_name,
394408
'executor_uuid': self.executor_uuid,
395409
'worker_logs': json.dumps(wlogs),
396410
'output_processor_logs': json.dumps(oplogs),
411+
'lats_logs': json.dumps(latslogs),
397412
'syslogs': json.dumps(syslogs),
398413
}
399414

output_processor/output.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def output_processor_fn(rank: int, output_log_path: str, event: threading.Event,
2525
# sys.stdout = Tee(sys.stdout, f)
2626

2727
sys.stdout = Logger(os.path.join(output_log_path, "output_processor_logs.txt"), 'a+')
28-
28+
lats_f = open(os.path.join(output_log_path, "lats.txt"), "a+")
2929
from common.db import DataBase
3030
from output_processor import queue, broker
3131

@@ -191,6 +191,9 @@ def thread_fn(rank, event: threading.Event):
191191
with open(os.path.join(lats_path, job.assignment_id, f"{job.assignment_id}_{job.submission_id}.json"), "w+") as lats_fp:
192192
json.dump(lats, lats_fp, ensure_ascii=False, indent=4)
193193

194+
lats_f.write(f"[{get_datetime()}] [output_processor]\tTeam : {teamId} Assignment ID : {assignmentId}_{submissionId} | Wait : {lats_summary['waiting_time']:.4f}s Processing : {lats_summary['processing_time']:.4f}s Total: {lats_summary['total_time']:.4f}s\n")
195+
lats_f.flush()
196+
194197
#end of thread_fn
195198
threads : List[threading.Thread] = []
196199
thread_events : List[threading.Event] = []

scripts/backend.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ windows:
99
- flask_backend:
1010
- sleep 10
1111
- gunicorn -w 4 --preload --timeout 90 --bind 0.0.0.0:9000 "flask_backend.backend:createApp()"
12-
- mailer:
13-
- sleep 12
14-
- python3 -m common.mailer
12+
# - mailer:
13+
# - sleep 12
14+
# - python3 -m common.mailer

scripts/evaluator.yaml

-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ windows:
1212
- mailer:
1313
- sleep 10
1414
- python3 -m common.mailer
15-
- output:
16-
- sleep 10
17-
- python3 -m output_processor.output
1815
- executor:
1916
- sleep 15
2017
- python3 -m job_tracker.executor

0 commit comments

Comments
 (0)