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

list: optimize -R/--recursive #8135

Closed
efiop opened this issue Aug 16, 2022 · 5 comments
Closed

list: optimize -R/--recursive #8135

efiop opened this issue Aug 16, 2022 · 5 comments
Assignees
Labels

Comments

@efiop
Copy link
Contributor

efiop commented Aug 16, 2022

http://bench.dvc.org/
Screenshot 2022-08-16 at 15 32 39

@efiop efiop added research optimize Optimizes DVC labels Aug 16, 2022
@rlamy
Copy link
Member

rlamy commented Aug 17, 2022

A significant part of the recent performance regression comes from 4965995, specifically this line:

if fs.isdvc(info["name"], recursive=True) or not dvc_only:

We could swipe that issue under the rug by swapping the arguments of the or, but looking at the rest of the code in _ls(), that fs.isdvc() seems redundant.

But the main issue seems to be that there are a lot of redundant path operations, splitting and recombining them multiple times in _DvcFileSystem.info() and similar methods.

@efiop
Copy link
Contributor Author

efiop commented Aug 24, 2022

📉

Screenshot 2022-08-24 at 13 35 03

@rlamy
Copy link
Member

rlamy commented Sep 8, 2022

After #8241 is merged, there will still be a few easy targets for optimisation:

  • _DvcFileSystem.ls() shouldn't call ._info() but rather directly gather the relevant info from the underlying fs/dvc_fs, using .ls(.., detail=True).
  • _info() ends up calling _update() on every file that is passed to it, it should probably only do that for directories. (Note that the impact of this is compounded by the previous point).
  • In dvc.repo.ls._ls(), the following lines take 30% of the run-time just to convert filenames into paths:

    dvc/dvc/repo/ls.py

    Lines 73 to 76 in 8432de5

    for name, entry in files.items():
    entry_fs_path = fs.path.join(root, name)
    relparts = fs.path.relparts(entry_fs_path, fs_path)
    name = os.path.join(*relparts)

@efiop
Copy link
Contributor Author

efiop commented Jan 9, 2023

Turns out I accidentally re-discovered and fixed all three points from @rlamy 's research ^

Fixed by #8779 and #8780 . Closing.

Kudos @rlamy 🙏

@efiop efiop closed this as completed Jan 9, 2023
@efiop
Copy link
Contributor Author

efiop commented Jan 9, 2023

For the record, this is how it looks now
Screenshot 2023-01-09 at 22 02 03

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Archived in project
Development

No branches or pull requests

2 participants