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

Use gc.collect only when needed to avoid slow downs #2483

Merged
merged 2 commits into from
Jun 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/datasets/arrow_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,10 +553,6 @@ def __del__(self):
del self._data
if hasattr(self, "_indices"):
del self._indices
# collect the gc to make sure the windows file lock on arrow files is gone
import gc

gc.collect()

def __enter__(self):
return self
Expand Down
5 changes: 5 additions & 0 deletions src/datasets/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,11 @@ def _build_single_dataset(
}
post_processed = self._post_process(ds, resources_paths)
if post_processed is not None:
del ds
# collect the gc to make sure the windows file lock on arrow files is gone
import gc

gc.collect()
ds = post_processed
recorded_checksums = {}
for resource_name, resource_path in resources_paths.items():
Expand Down