@@ -55,52 +55,16 @@ def load_trace(trace_directorypath):
5555 trace_functions = {}
5656
5757 for _ , row in duration_info .iterrows ():
58- hash_function = row ["HashFunction" ]
59- trace_functions [hash_function ] = {}
60- trace_functions [hash_function ]["duration" ] = row
58+ unique_id = row ["HashFunction" ] + row [ "HashOwner" ] + row [ "HashApp " ]
59+ trace_functions [unique_id ] = {}
60+ trace_functions [unique_id ]["duration" ] = row
6161
6262 for _ , row in memory_info .iterrows ():
63- hash_function = row ["HashFunction" ]
64- trace_functions [hash_function ]["memory" ] = row
63+ unique_id = row ["HashFunction" ] + row [ "HashOwner" ] + row [ "HashApp " ]
64+ trace_functions [unique_id ]["memory" ] = row
6565
6666 return trace_functions , 0
6767
68- def generate_plot (trace_directorypath , trace_functions , proxy_functions , mapped_trace , invocation_statistics = True ):
69-
70- if invocation_statistics :
71- invocations = pd .read_csv (trace_directorypath + "/invocations.csv" )
72- inv_df = {}
73- for i in range (len (invocations )):
74- inv_df [invocations ["HashFunction" ][i ]] = sum ([invocations [col ][i ] if col not in invocations .columns [0 :INVOCATION_COLUMN ] else 0 for col in invocations .columns ])
75-
76- trace_durations = []
77- mapped_durations = []
78- dropped_functions , dropped_invocations , total_invocations = 0 , 0 , 0
79- for trace in trace_functions :
80- duration = trace_functions [trace ]["duration" ]["50-percentile" ]
81- if duration > VSWARM_MAX_DUR :
82- dropped_functions += 1
83- dropped_invocations += inv_df [trace ]
84- continue
85- total_invocations += inv_df [trace ]
86- proxy_name = mapped_trace [trace ]["proxy-function" ]
87- profile_duration = proxy_functions [proxy_name ]["duration" ]["50-percentile" ]
88- trace_durations .append (duration )
89- mapped_durations .append (profile_duration )
90- return trace_durations , mapped_durations , dropped_functions , (dropped_invocations / total_invocations )* 100
91- else :
92- trace_durations = []
93- mapped_durations = []
94- for trace in trace_functions :
95- duration = trace_functions [trace ]["duration" ]["50-percentile" ]
96- if duration > VSWARM_MAX_DUR :
97- continue
98- proxy_name = mapped_trace [trace ]["proxy-function" ]
99- profile_duration = proxy_functions [proxy_name ]["duration" ]["50-percentile" ]
100- trace_durations .append (duration )
101- mapped_durations .append (profile_duration )
102- return trace_durations , mapped_durations
103-
10468def main ():
10569 # Parse the arguments
10670 parser = argparse .ArgumentParser (description = "Mapper" )
@@ -160,9 +124,9 @@ def main():
160124
161125 # Only give function name and proxy name
162126 trace_json = {}
163- for function in trace_functions :
164- trace_json [function ] = {}
165- trace_json [function ]["proxy-function" ] = trace_functions [function ]["proxy-function" ]
127+ for id in trace_functions :
128+ trace_json [id ] = {}
129+ trace_json [id ]["proxy-function" ] = trace_functions [id ]["proxy-function" ]
166130
167131 try :
168132 with open (output_filepath , "w" ) as jf :
@@ -173,15 +137,7 @@ def main():
173137 return
174138
175139 log .info (f"Output file { output_filepath } written" )
176- log .info (f"Preliminary load Generation successful. Checking error levels in mapping..." )
177-
178- # Read the mapper output
179- try :
180- with open (output_filepath , "r" ) as jf :
181- mapper_output = json .load (jf )
182- except Exception as e :
183- log .critical (f"Error in loading mapper output file { e } " )
184- return
140+ log .info (f"Load Generation successful. Mapper output generated." )
185141
186142 # Check the memory and duration errors
187143
@@ -195,11 +151,14 @@ def main():
195151 abs_rel_mem_error = 0
196152 abs_rel_dur_error = 0
197153 zero_duration = 0
198- for function in mapper_output :
199- trace_mem = trace_functions [function ]["memory" ]["50-percentile" ]
200- trace_dur = trace_functions [function ]["duration" ]["50-percentile" ]
201- proxy_dur = proxy_functions [mapper_output [function ]["proxy-function" ]]["duration" ]["50-percentile" ]
202- proxy_mem = proxy_functions [mapper_output [function ]["proxy-function" ]]["memory" ]["50-percentile" ]
154+ for id in trace_functions :
155+ if trace_functions [id ]["proxy-function" ] == "trace-func-go" :
156+ dur_count += 1
157+ continue
158+ trace_mem = trace_functions [id ]["memory" ]["50-percentile" ]
159+ trace_dur = trace_functions [id ]["duration" ]["50-percentile" ]
160+ proxy_dur = proxy_functions [trace_functions [id ]["proxy-function" ]]["duration" ]["50-percentile" ]
161+ proxy_mem = proxy_functions [trace_functions [id ]["proxy-function" ]]["memory" ]["50-percentile" ]
203162 mem_error += trace_mem - proxy_mem
204163 rel_mem_error += (trace_mem - proxy_mem )/ trace_mem
205164 abs_mem_error += abs (trace_mem - proxy_mem )
@@ -211,11 +170,8 @@ def main():
211170 else :
212171 rel_dur_error += (trace_dur - proxy_dur )/ trace_dur
213172 abs_rel_dur_error += abs ((trace_dur - proxy_dur )/ trace_dur )
214- if abs (trace_dur - proxy_dur ) > 0.4 * trace_dur :
215- mapper_output [function ]["proxy-function" ] = "trace-func-go"
216- dur_count += 1
217173
218- total_functions = len (mapper_output )
174+ total_functions = len (trace_functions )
219175 log .info (f"Average memory error: { mem_error / total_functions } MB per invocation" )
220176 log .info (f"Average duration error: { dur_error / total_functions } ms per invocation" )
221177 log .info (f"Average absolute memory error: { abs_mem_error / total_functions } MB per invocation" )
@@ -227,18 +183,5 @@ def main():
227183 log .info (f"Duration errors: { dur_count } " )
228184 log .info (f"Functions with 0 duration: { zero_duration } " )
229185
230- log .info (f"Replacing the functions with high duration error with invitro functions." )
231-
232- ## Write the updated mapper output
233-
234- try :
235- with open (output_filepath , "w" ) as jf :
236- json .dump (mapper_output , jf , indent = 4 )
237- log .info (f"Updated output file { output_filepath } written. Load generated." )
238- except Exception as e :
239- log .critical (f"Output file { output_filepath } cannot be written. Error: { e } " )
240- log .critical (f"Load Generation failed" )
241- return
242-
243186if __name__ == "__main__" :
244187 main ()
0 commit comments