forked from ray-project/ray
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[core] Fix bug in fusion for spilled objects (ray-project#22571)
Whenever we spill, we try to spill all spillable objects. We also try to fuse small objects together to reduce total IOPS. If there aren't enough objects in the object store to meet the fusion threshold, we spill the objects anyway to avoid liveness issues. However, the current logic always spills once we reach the end of the spillable objects or once we've reached the fusion threshold. This can produce lots of unfused objects if they are created concurrently with the spill. This PR changes the spill logic: once we reach the end of the spillable objects, if the last batch of spilled objects is under the fusion threshold, we'll only spill it if we don't have other spills pending too. This gives the pending spills time to finish, and then we can re-evaluate whether it's necessary to spill the remaining objects. Liveness is also preserved.
- Loading branch information
1 parent
ad41236
commit a370099
Showing
5 changed files
with
181 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import numpy as np | ||
import pytest | ||
import os | ||
import sys | ||
|
||
import ray | ||
|
||
|
||
# NOTE(swang): This test currently fails in ASAN mode because it tests a | ||
# performance issue that is likely sensitive to timing. | ||
def test_spill_fusion(object_spilling_config): | ||
# Limit our object store to 75 MiB of memory. | ||
object_spilling_config, temp_folder = object_spilling_config | ||
min_spilling_size = 10 * 1024 * 1024 | ||
ray.init( | ||
num_cpus=1, | ||
object_store_memory=75 * 1024 * 1024, | ||
_system_config={ | ||
"max_io_workers": 1, | ||
"object_spilling_config": object_spilling_config, | ||
"min_spilling_size": min_spilling_size, | ||
"object_spilling_threshold": 0.8, | ||
# Set the timeout between create retries high so that this test | ||
# passes in ASAN and debug mode. | ||
"object_store_full_delay_ms": 1000, | ||
}, | ||
) | ||
|
||
object_size = 1024 * 1024 | ||
# Fill up the object store 4 times with small objects. | ||
# We trigger spilling at 80% and the min spill size is | ||
# about 10 objects. | ||
xs = [ray.put(np.zeros(object_size // 8)) for _ in range(300)] # noqa: F841 | ||
|
||
spill_dir = os.path.join(temp_folder, ray.ray_constants.DEFAULT_OBJECT_PREFIX) | ||
under_min, over_min = 0, 0 | ||
for filename in os.listdir(spill_dir): | ||
size = os.stat(os.path.join(spill_dir, filename)).st_size | ||
if size < min_spilling_size: | ||
under_min += 1 | ||
else: | ||
over_min += 1 | ||
# We should almost always spill fused objects. | ||
assert over_min > under_min | ||
|
||
|
||
if __name__ == "__main__": | ||
sys.exit(pytest.main(["-sv", __file__])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters