@@ -79,24 +79,22 @@ def search(
7979
8080 if count % 500 == 0 :
8181 log .debug (
82- f"({ mp .current_process ().name :16} ) " ,
83- f"search_count: { count } , latest_latency={ time .perf_counter ()- s } " ,
82+ f"({ mp .current_process ().name :16} ) "
83+ f"search_count: { count } , latest_latency={ time .perf_counter ()- s } "
8484 )
8585
8686 total_dur = round (time .perf_counter () - start_time , 4 )
8787 log .info (
8888 f"{ mp .current_process ().name :16} search { self .duration } s: "
89- f"actual_dur={ total_dur } s, count={ count } , qps in this process: { round (count / total_dur , 4 ):3} " ,
89+ f"actual_dur={ total_dur } s, count={ count } , qps in this process: { round (count / total_dur , 4 ):3} "
9090 )
9191
9292 return (count , total_dur , latencies )
9393
9494 @staticmethod
9595 def get_mp_context ():
9696 mp_start_method = "spawn"
97- log .debug (
98- f"MultiProcessingSearchRunner get multiprocessing start method: { mp_start_method } " ,
99- )
97+ log .debug (f"MultiProcessingSearchRunner get multiprocessing start method: { mp_start_method } " )
10098 return mp .get_context (mp_start_method )
10199
102100 def _run_all_concurrencies_mem_efficient (self ):
@@ -113,9 +111,7 @@ def _run_all_concurrencies_mem_efficient(self):
113111 mp_context = self .get_mp_context (),
114112 max_workers = conc ,
115113 ) as executor :
116- log .info (
117- f"Start search { self .duration } s in concurrency { conc } , filters: { self .filters } " ,
118- )
114+ log .info (f"Start search { self .duration } s in concurrency { conc } , filters: { self .filters } " )
119115 future_iter = [executor .submit (self .search , self .test_data , q , cond ) for i in range (conc )]
120116 # Sync all processes
121117 while q .qsize () < conc :
@@ -124,9 +120,7 @@ def _run_all_concurrencies_mem_efficient(self):
124120
125121 with cond :
126122 cond .notify_all ()
127- log .info (
128- f"Syncing all process and start concurrency search, concurrency={ conc } " ,
129- )
123+ log .info (f"Syncing all process and start concurrency search, concurrency={ conc } " )
130124
131125 start = time .perf_counter ()
132126 all_count = sum ([r .result ()[0 ] for r in future_iter ])
@@ -140,18 +134,14 @@ def _run_all_concurrencies_mem_efficient(self):
140134 conc_qps_list .append (qps )
141135 conc_latency_p99_list .append (latency_p99 )
142136 conc_latency_avg_list .append (latency_avg )
143- log .info (
144- f"End search in concurrency { conc } : dur={ cost } s, total_count={ all_count } , qps={ qps } " ,
145- )
137+ log .info (f"End search in concurrency { conc } : dur={ cost } s, total_count={ all_count } , qps={ qps } " )
146138
147139 if qps > max_qps :
148140 max_qps = qps
149- log .info (
150- f"Update largest qps with concurrency { conc } : current max_qps={ max_qps } " ,
151- )
141+ log .info (f"Update largest qps with concurrency { conc } : current max_qps={ max_qps } " )
152142 except Exception as e :
153143 log .warning (
154- f"Fail to search all concurrencies: { self .concurrencies } , max_qps before failure={ max_qps } , reason={ e } " ,
144+ f"Fail to search, concurrencies: { self .concurrencies } , max_qps before failure={ max_qps } , reason={ e } "
155145 )
156146 traceback .print_exc ()
157147
@@ -193,9 +183,7 @@ def _run_by_dur(self, duration: int) -> float:
193183 mp_context = self .get_mp_context (),
194184 max_workers = conc ,
195185 ) as executor :
196- log .info (
197- f"Start search_by_dur { duration } s in concurrency { conc } , filters: { self .filters } " ,
198- )
186+ log .info (f"Start search_by_dur { duration } s in concurrency { conc } , filters: { self .filters } " )
199187 future_iter = [
200188 executor .submit (self .search_by_dur , duration , self .test_data , q , cond ) for i in range (conc )
201189 ]
@@ -206,24 +194,18 @@ def _run_by_dur(self, duration: int) -> float:
206194
207195 with cond :
208196 cond .notify_all ()
209- log .info (
210- f"Syncing all process and start concurrency search, concurrency={ conc } " ,
211- )
197+ log .info (f"Syncing all process and start concurrency search, concurrency={ conc } " )
212198
213199 start = time .perf_counter ()
214200 all_count = sum ([r .result () for r in future_iter ])
215201 cost = time .perf_counter () - start
216202
217203 qps = round (all_count / cost , 4 )
218- log .info (
219- f"End search in concurrency { conc } : dur={ cost } s, total_count={ all_count } , qps={ qps } " ,
220- )
204+ log .info (f"End search in concurrency { conc } : dur={ cost } s, total_count={ all_count } , qps={ qps } " )
221205
222206 if qps > max_qps :
223207 max_qps = qps
224- log .info (
225- f"Update largest qps with concurrency { conc } : current max_qps={ max_qps } " ,
226- )
208+ log .info (f"Update largest qps with concurrency { conc } : current max_qps={ max_qps } " )
227209 except Exception as e :
228210 log .warning (
229211 f"Fail to search all concurrencies: { self .concurrencies } , max_qps before failure={ max_qps } , reason={ e } " ,
@@ -275,14 +257,14 @@ def search_by_dur(
275257
276258 if count % 500 == 0 :
277259 log .debug (
278- f"({ mp .current_process ().name :16} ) search_count: { count } , " ,
279- f"latest_latency={ time .perf_counter ()- s } " ,
260+ f"({ mp .current_process ().name :16} ) search_count: { count } , "
261+ f"latest_latency={ time .perf_counter ()- s } "
280262 )
281263
282264 total_dur = round (time .perf_counter () - start_time , 4 )
283265 log .debug (
284266 f"{ mp .current_process ().name :16} search { self .duration } s: "
285- f"actual_dur={ total_dur } s, count={ count } , qps in this process: { round (count / total_dur , 4 ):3} " ,
267+ f"actual_dur={ total_dur } s, count={ count } , qps in this process: { round (count / total_dur , 4 ):3} "
286268 )
287269
288270 return count
0 commit comments