1
1
"""This is the script for `ray microbenchmark`."""
2
2
3
- import asyncio
4
3
import os
5
4
import time
6
5
import numpy as np
@@ -23,18 +22,6 @@ def small_value_batch(self, n):
23
22
ray .get ([small_value .remote () for _ in range (n )])
24
23
25
24
26
- @ray .remote
27
- class AsyncActor :
28
- async def small_value (self ):
29
- return b"ok"
30
-
31
- async def small_value_with_arg (self , x ):
32
- return b"ok"
33
-
34
- async def small_value_batch (self , n ):
35
- await asyncio .wait ([small_value .remote () for _ in range (n )])
36
-
37
-
38
25
@ray .remote (num_cpus = 0 )
39
26
class Client :
40
27
def __init__ (self , servers ):
@@ -203,51 +190,6 @@ def actor_multi2_direct_arg():
203
190
timeit ("n:n actor calls with arg async" , actor_multi2_direct_arg ,
204
191
n * len (clients ))
205
192
206
- a = AsyncActor .remote ()
207
-
208
- def actor_sync ():
209
- ray .get (a .small_value .remote ())
210
-
211
- timeit ("1:1 async-actor calls sync" , actor_sync )
212
-
213
- a = AsyncActor .remote ()
214
-
215
- def async_actor ():
216
- ray .get ([a .small_value .remote () for _ in range (1000 )])
217
-
218
- timeit ("1:1 async-actor calls async" , async_actor , 1000 )
219
-
220
- a = AsyncActor .remote ()
221
-
222
- def async_actor ():
223
- ray .get ([a .small_value_with_arg .remote (i ) for i in range (1000 )])
224
-
225
- timeit ("1:1 async-actor calls with args async" , async_actor , 1000 )
226
-
227
- n = 5000
228
- n_cpu = multiprocessing .cpu_count () // 2
229
- actors = [AsyncActor .remote () for _ in range (n_cpu )]
230
- client = Client .remote (actors )
231
-
232
- def async_actor_async ():
233
- ray .get (client .small_value_batch .remote (n ))
234
-
235
- timeit ("1:n async-actor calls async" , async_actor_async , n * len (actors ))
236
-
237
- n = 5000
238
- m = 4
239
- n_cpu = multiprocessing .cpu_count () // 2
240
- a = [AsyncActor .remote () for _ in range (n_cpu )]
241
-
242
- @ray .remote
243
- def async_actor_work (actors ):
244
- ray .get ([actors [i % n_cpu ].small_value .remote () for i in range (n )])
245
-
246
- def async_actor_multi ():
247
- ray .get ([async_actor_work .remote (a ) for _ in range (m )])
248
-
249
- timeit ("n:n async-actor calls async" , async_actor_multi , m * n )
250
-
251
193
252
194
if __name__ == "__main__" :
253
195
main ()
0 commit comments