Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Datasets] [Out-of-Band Serialization: 2/3] Refactor ExecutionPlan to maintain complete lineage and eagerly unlink block references. #23931

Conversation

clarkzinzow
Copy link
Contributor

This PR refactors ExecutionPlan to maintain complete stage lineage, even for eagerly computed datasets, while ensuring that block references are unlinked as early as possible in order to more eagerly release block memory. This PR is the final precursor to adding the actual out-of-band serialization APIs (PR 3/3).

The fully lineage has to be maintained, even for eagerly computed datasets, since the lineage is needed for out-of-band serialization of datasets. See the mono-PR for more context.

Checks

  • I've run scripts/format.sh to lint the changes in this PR.
  • I've included any doc changes needed for https://docs.ray.io/en/master/.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
  • Testing Strategy
    • Unit tests
    • Release tests
    • This PR is not tested :(

@clarkzinzow clarkzinzow force-pushed the datasets/feat/refactor-execution-plan branch from a4d2f71 to b4a2cbd Compare April 15, 2022 00:47
@ericl
Copy link
Contributor

ericl commented Apr 15, 2022

Does uncommenting this line in test work after the changes here?

# TODO(ekl) we can add this back once we clear inputs on eager exec as well.

@@ -87,11 +87,13 @@ def test_spread_hint_inherit(ray_start_regular_shared):
ds = ray.data.range(10)._experimental_lazy()
ds = ds.map(lambda x: x + 1)
ds = ds.random_shuffle()
for s in ds._plan._stages:
for s in ds._plan._stages_before_snapshot:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great to have more tests for this unlinking behavior as it's fairly intricate.

@ericl ericl added the @author-action-required The PR author is responsible for the next step. Remove tag to send back to the reviewer. label Apr 15, 2022
python/ray/data/impl/plan.py Show resolved Hide resolved
python/ray/data/impl/plan.py Outdated Show resolved Hide resolved
python/ray/data/impl/plan.py Show resolved Hide resolved
python/ray/data/impl/plan.py Outdated Show resolved Hide resolved
python/ray/data/impl/plan.py Outdated Show resolved Hide resolved
@clarkzinzow clarkzinzow force-pushed the datasets/feat/refactor-execution-plan branch from bb55429 to e27926d Compare April 20, 2022 01:46
@clarkzinzow clarkzinzow force-pushed the datasets/feat/refactor-execution-plan branch from fa1c84b to f13a2da Compare April 22, 2022 16:05
Copy link
Contributor

@jianoaix jianoaix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done, LGTM

dataset_uuid = self._dataset_uuid
in_blocks = self._in_blocks
if isinstance(in_blocks, BlockList):
in_blocks = in_blocks.copy()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it actually deep copy? The blocklist copy API used here is a shallow copy: https://sourcegraph.com/github.com/ray-project/ray@78d6ed7/-/blob/python/ray/data/impl/block_list.py?L37

Copy link
Contributor Author

@clarkzinzow clarkzinzow Apr 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The execution plan only consumes those BlockList-internal lists (blocks and metadata), it doesn't mutate them, so it's a "deep" copy as we define it in the docstring: "This copy can be executed AND cleared without mutating the original."

@clarkzinzow clarkzinzow merged commit 9ee2453 into ray-project:master Apr 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@author-action-required The PR author is responsible for the next step. Remove tag to send back to the reviewer.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants