# Small Ray objects

**URL:** <https://discuss.ray.io/t/small-ray-objects/13473>\
**Category:** Ray Core\
**Created:** [January 19, 2024, 9:42am UTC](https://discuss.ray.io/t/small-ray-objects/13473 "2024-01-19T09:42:34Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![YarShev](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/yarshev/32/638_2.png) [@YarShev](https://discuss.ray.io/u/YarShev)\
**Post date:** [January 19, 2024, 9:42am UTC](https://discuss.ray.io/t/small-ray-objects/13473/1 "2024-01-19T09:42:34Z")

</div>

**How severe does this issue affect your experience of using Ray?**

- High: It blocks me to complete my task.

Hi there,

By reading the Ray arch document I got confused by the following paragraph.

```auto
For remote tasks, the object value is computed by the executing worker. If the value is small, the worker replies directly to the owner with the value, which is copied into the owner’s in-process store.

```

Let’s say we have an example code like this.

```python
import ray

ray.init()

@ray.remote
def foo():
    return 1

o_ref = foo.remote()

```

Upon competion of `foo` will the returned value be copied directly to the driver process even without calling `ray.get`? Or is the returned value just stored in-process memory of the executing worker?

---

<div class="post-metadata">

**Author:** ![YarShev](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/yarshev/32/638_2.png) [@YarShev](https://discuss.ray.io/u/YarShev)\
**Post date:** [January 25, 2024, 9:13am UTC](https://discuss.ray.io/t/small-ray-objects/13473/2 "2024-01-25T09:13:39Z")

</div>

@sangcho, could you shed the light on this?

---

<div class="post-metadata">

**Author:** ![sangcho](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/sangcho/32/425_2.png) [@sangcho](https://discuss.ray.io/u/sangcho)\
**Post date:** [January 25, 2024, 12:29pm UTC](https://discuss.ray.io/t/small-ray-objects/13473/3 "2024-01-25T12:29:54Z")

</div>

So, if the returned data is smaller than 100KB, it is always copied. if it is bigger, it is put into the object store (which supports zero-copy for numpy array).

---

<div class="post-metadata">

**Author:** ![YarShev](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/yarshev/32/638_2.png) [@YarShev](https://discuss.ray.io/u/YarShev)\
**Post date:** [January 25, 2024, 1:02pm UTC](https://discuss.ray.io/t/small-ray-objects/13473/4 "2024-01-25T13:02:53Z")

</div>

@sangcho, yes, I got the point when the data is copied and when it is not. My questions is if the “small” object is stored in the executing worker or it is right away copied into the worker that called the remote function without calling ray.get?

---

<div class="post-metadata">

**Author:** ![YarShev](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/yarshev/32/638_2.png) [@YarShev](https://discuss.ray.io/u/YarShev)\
**Post date:** [February 6, 2024, 8:59am UTC](https://discuss.ray.io/t/small-ray-objects/13473/5 "2024-02-06T08:59:04Z")

</div>

@sangcho, just a friendly reminder.

---

<div class="post-metadata">

**Author:** ![sangcho](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/sangcho/32/425_2.png) [@sangcho](https://discuss.ray.io/u/sangcho)\
**Post date:** [February 6, 2024, 2:34pm UTC](https://discuss.ray.io/t/small-ray-objects/13473/6 "2024-02-06T14:34:19Z")

</div>

Sorry for the delay.

> My questions is if the “small” object is stored in the executing worker or it is right away copied into the worker that called the remote function without calling ray.get?

Both worker (the caller and the owner) will have the copy

---

<div class="post-metadata">

**Author:** ![YarShev](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/yarshev/32/638_2.png) [@YarShev](https://discuss.ray.io/u/YarShev)\
**Post date:** [February 6, 2024, 2:47pm UTC](https://discuss.ray.io/t/small-ray-objects/13473/7 "2024-02-06T14:47:52Z")

</div>

So the second copy happens when calling ray.get() in the caller, right?

---

<div class="post-metadata">

**Author:** ![sangcho](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/sangcho/32/425_2.png) [@sangcho](https://discuss.ray.io/u/sangcho)\
**Post date:** [February 7, 2024, 3:52am UTC](https://discuss.ray.io/t/small-ray-objects/13473/9 "2024-02-07T03:52:18Z")

</div>

I think it happens when you call a remote method.

---

<div class="post-metadata">

**Author:** ![YarShev](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/yarshev/32/638_2.png) [@YarShev](https://discuss.ray.io/u/YarShev)\
**Post date:** [February 7, 2024, 8:04am UTC](https://discuss.ray.io/t/small-ray-objects/13473/10 "2024-02-07T08:04:33Z")

</div>

@sangcho, this behaviour is not obvious. I wonder if you know someone who has more insight on this to be sure about the behaviour? Is it highlighted somewhere else in docs?

---

<div class="post-metadata">

**Author:** ![sangcho](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/sangcho/32/425_2.png) [@sangcho](https://discuss.ray.io/u/sangcho)\
**Post date:** [February 7, 2024, 9:23am UTC](https://discuss.ray.io/t/small-ray-objects/13473/11 "2024-02-07T09:23:38Z")

</div>

that should be me. I just checked code, and it should be copied when a task is finished (regardless of ray.get). [ray/src/ray/protobuf/core\_worker.proto at ccfcb21c9ad9960604a349155300c55698e2e971 · ray-project/ray · GitHub](https://github.com/ray-project/ray/blob/ccfcb21c9ad9960604a349155300c55698e2e971/src/ray/protobuf/core_worker.proto#L94)

if is\_plasma == true, it won’t return the copy. Otherwise, it includes the copy

---

<div class="post-metadata">

**Author:** ![YarShev](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/yarshev/32/638_2.png) [@YarShev](https://discuss.ray.io/u/YarShev)\
**Post date:** [February 7, 2024, 2:40pm UTC](https://discuss.ray.io/t/small-ray-objects/13473/12 "2024-02-07T14:40:00Z")

</div>

Okay, then I accept the fact the callee replies to the caller with returned data copy. Please correct if this is wrong. Thanks for answering my questions!
