# Delay ray.get() seems cannot speed up for actors

**URL:** <https://discuss.ray.io/t/delay-ray-get-seems-cannot-speed-up-for-actors/6428>\
**Category:** Ray Core\
**Created:** [June 8, 2022, 11:02am UTC](https://discuss.ray.io/t/delay-ray-get-seems-cannot-speed-up-for-actors/6428 "2022-06-08T11:02:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![GoingMyWay](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/goingmyway/32/1102_2.png) [@GoingMyWay](https://discuss.ray.io/u/GoingMyWay)\
**Post date:** [June 8, 2022, 11:02am UTC](https://discuss.ray.io/t/delay-ray-get-seems-cannot-speed-up-for-actors/6428/1 "2022-06-08T11:02:00Z")

</div>

Hi, I followed [the tip](https://docs.ray.io/en/releases-1.11.0/ray-core/examples/tips-for-first-time.html#tip-1-delay-ray-get) and created actors to test this tip. However, I found there is no speed up for actors. Here is the code

```python
import time
import logging

import ray
import numpy as np

logging.basicConfig(level=logging.INFO)

@ray.remote
class Runner(object):
    def run(self):
        pass

    def get_global_t_(self):
        time.sleep(1)
        return 1

ray.init(num_cpus=4)

runners = [Runner.options(name=f'Runner_{i}').remote() for i in range(4)]

st = time.time()
results = [r.get_global_t_.remote() for r in runners]
results = ray.get(results)
t_cost = time.time() - st
logging.info(f"results: {results}, time cost: {t_cost}")
ray.shutdown()

```

and the output:

```bash
$ python tip.py 
2022-06-08 19:00:37,471 INFO services.py:1462 -- View the Ray dashboard at http://127.0.0.1:8265
INFO:root:results: [1, 1, 1, 1], time cost: 4.214106321334839

```

The expected duration is 1 second, however, it costs ~4 seconds. Does this tip apply to actors?

Ray version: 1.12.1, Python: 3.7

---

<div class="post-metadata">

**Author:** ![yic](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/yic/32/437_2.png) [@yic](https://discuss.ray.io/u/yic)\
**Post date:** [June 8, 2022, 7:50pm UTC](https://discuss.ray.io/t/delay-ray-get-seems-cannot-speed-up-for-actors/6428/2 "2022-06-08T19:50:31Z")

</div>

@GoingMyWay the reason is that actor need some time to be created. So for your case, the extra 3s probably are spent on creating the actors.

Here is my updated code for your reference:

```auto
import time
import logging

import ray
import numpy as np

logging.basicConfig(level=logging.INFO)

@ray.remote
class Runner(object):
    def ready(self):
        pass
    def run(self):
        pass

    def get_global_t_(self):
        time.sleep(1)
        return 1

ray.init(num_cpus=4)

runners = [Runner.options(name=f'Runner_{i}').remote() for i in range(4)]

ray.get([r.ready.remote() for r in runners])

st = time.time()
results = [r.get_global_t_.remote() for r in runners]
results = ray.get(results)
t_cost = time.time() - st
logging.info(f"results: {results}, time cost: {t_cost}")

st = time.time()
results = [r.get_global_t_.remote() for r in runners]
results = ray.get(results)
t_cost = time.time() - st
logging.info(f"results: {results}, time cost: {t_cost}")

ray.shutdown()

```

And the result is:

```auto
2022-06-08 19:49:03,251 INFO services.py:1477 -- View the Ray dashboard at http://127.0.0.1:8265
INFO:root:results: [1, 1, 1, 1], time cost: 1.0063087940216064
INFO:root:results: [1, 1, 1, 1], time cost: 1.0064780712127686

```

Here `ready` is just a placeholder to make sure the actors are created successfully.

---

<div class="post-metadata">

**Author:** ![GoingMyWay](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/goingmyway/32/1102_2.png) [@GoingMyWay](https://discuss.ray.io/u/GoingMyWay)\
**Post date:** [June 9, 2022, 3:34am UTC](https://discuss.ray.io/t/delay-ray-get-seems-cannot-speed-up-for-actors/6428/3 "2022-06-09T03:34:09Z")

</div>

Thank you. It is true that actor was not fully initialised.
