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

fix(fs): add dirs caching, make it a bit more robust #322

Merged
merged 1 commit into from
Dec 25, 2023

Conversation

shcheklein
Copy link
Member

@shcheklein shcheklein commented Dec 20, 2023

Caching mechanics was broken in certain scenarios and affected DVC tremendously. Before we were assuming pre-cached paths for 00, 01 .... ff in DVC. It got broken during DVC 3.0 release, and then got removed completely because of this. Now it's not the case and DVC was kept asking for files, files\md5, etc - all those IDs again and again and again on dvc pull. Pretty much every object could be 3x slower to download.

Among other things, I checked that dvc pull works now even with duplicated root dirs in DVC remote.

Still need to self review this, and next see if we can add tests for all of this. It keeps biting us. Caching is non trivial and we cant be losing the knowledge as we go, every time coming back to fix it after users complain.

cache["ids"][item_id] = path
cache["dirs"][path].append(item_id)
Copy link
Member Author

Choose a reason for hiding this comment

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

C: This is better to do in this order since we always refer first to dirs to decide id item is cached or not. Still looks fragile, and we still ideally should be using proper locking. I'll looking into this as a follow up.

Copy link
Member

Choose a reason for hiding this comment

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

IIRC, this is not true in find where we use ids first.

Copy link
Member

Choose a reason for hiding this comment

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

Ahh, I see that you also changed find below.

res.append(item["id"])

if item["mimeType"] == FOLDER_MIME_TYPE:
self._cache_path_id(
Copy link
Member Author

Choose a reason for hiding this comment

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

C: This is the main change here. It was missing and DVC kept hitting _get_remote_item_ids with the same queries like files/md5, etc.

dir_ids = self._ids_cache["dirs"][base]
else:
dir_ids = self._path_to_item_ids(base)
dir_ids = self._path_to_item_ids(base)
Copy link
Member Author

Choose a reason for hiding this comment

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

C: since now self._path_to_item_ids(base) also does caching it's not clear why we should have a separate check above. I need to review this one more time though. The same applies in the find below, and removal of the cache calls since we now call cache inside path_to_item_ids.

@shcheklein
Copy link
Member Author

@efiop @skshetry gentle reminder folks. I think it would be good to merge this to fix the gdrive remote support. When you have time.

@shcheklein shcheklein merged commit be873e6 into main Dec 25, 2023
16 checks passed
@shcheklein shcheklein deleted the fix-fsspec-cache-management branch December 25, 2023 05:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants