Skip to content

ls **/* command is not streaming #6174

Closed

Description

@wmstack

Describe the bug

The command above does not stream a table of output to autoview, but the user must keep waiting around until the table is fully complete. That is a downgrade from a shell like bash, where you don't have to wait for all the data to finish loading before you can read it.

How to reproduce

  1. Open a relatively large directory
  2. Open Nushell and type ls **/*
  3. You have to wait for a period of time before you see anything

Expected behavior

I expected the ls **/* command to stream output as advertised in the README. However, it doesn't stream output for large files and the user is stuck without even a progress bar.

Screenshots

image

It almost feels frozen for a long time. It should output a table that keeps updating, rather than this lazy stream. Also if you pipe to fzf, you have to wait for the stream to complete before you see any file.

Configuration

key value
version 0.66.3
branch
commit_hash 5f11be6
build_os windows-x86_64
build_target x86_64-pc-windows-msvc
rust_version rustc 1.62.1 (e092d0b6b 2022-07-16)
rust_channel stable-x86_64-pc-windows-msvc
cargo_version cargo 1.62.1 (a748cf5a3 2022-06-08)
pkg_version 0.66.3
build_time 2022-07-28 23:20:39 +00:00
build_rust_channel release
features database, dataframe, default, trash, which, zip
installed_plugins

Additional context

This isn't scalable. If the user happens to be in the home directory, it could take longer than a minute for anything to appear at all. It really takes a disproportionately large period of time.

Autoview should be smart. It should page the table when it finally arrives and should keep it to a consistent width. Commands like fzf should recieve a list of increasing size, but shouldn't make you have to wait to start searching.

Activity

  1. added
    delight
    polish
    on Jul 29, 2022
  2. kubouch commented on Jul 29, 2022

    @kubouch
    Contributor

    Does it still happen? We reverted the ls changes that likely caused this.

  3. wmstack commented on Jul 29, 2022

    @wmstack
    Author

    Yup, I reported it today, and it happened today. 0.66.1 is the latest version right?

  4. kubouch commented on Jul 29, 2022

    @kubouch
    Contributor

    0.66.2, we made another hotfix.

  5. wmstack commented on Jul 29, 2022

    @wmstack
    Author

    Hmm, I wouldn't be able to run it right now, because it would need to trickle down into scoop. I have installed ripgrep as rg --files kind of does the streaming as I want anyway. Still, would love some polish on nushell.

    Edit: I realized that the update had reached scoop. I have updated it to 0.66.2. Still frozen when I run it:
    image
    Even running ls **/* by itself still makes it remain frozen. Just in case you hypothesize that to text breaks the streaming.

  6. kubouch commented on Jul 29, 2022

    @kubouch
    Contributor

    On my end, running ls **/* streams while previously it waited first. So it seems to me the issues is solved.

    And yes, to text collects the stream.

    I'll close this issue then but we can discuss the stream collecting in general in another issue (maybe there is one already).

  7. added this to the v0.67.0 milestone on Jul 29, 2022
  8. wmstack commented on Jul 29, 2022

    @wmstack
    Author

    ls **/* is streaming when I do it from my desktop, but when I do it for the home directory, it is frozen:

    image

    Perhaps because the files that ls tries to read might be open in other programs for the home directory, while those files in the desktop directory are most likely not to be open in an external program.

    Edit: It is streaming, but takes a long time to start streaming (about 40s).

  9. wmstack commented on Jul 29, 2022

    @wmstack
    Author

    @kubouch is there a chance that the starting performance for large directories such as the home directory might be improved? I do not need to wait for rg --file to start the stream, even for the home directory. However, Nushell currently takes about 40s to start streaming.

  10. kubouch commented on Jul 29, 2022

    @kubouch
    Contributor

    I'm not sure why you're seeing the 40s pause. For me on Linux, it starts streaming immediately. I'll reopen this until we find a cause of this.

    Can you update the version in the issue description to the 0.66.2?

  11. wmstack commented on Jul 29, 2022

    @wmstack
    Author

    It is odd that scoop says I have version 0.66.2 while version outputs 0.66.3 :)

  12. kubouch commented on Jul 30, 2022

    @kubouch
    Contributor

    Yeah, somehow the versions got messed up with the recent hotfixes. 0.67.0 comes 16th of August so that's when the versions should match again, at the latest.

  13. modified the milestones: v0.67.0, v0.68.0 on Aug 17, 2022
  14. added
    performance
    on Aug 31, 2022
  15. removed this from the v0.68.0 milestone on Sep 7, 2022
  16. rgwood commented on Dec 9, 2022

    @rgwood
    Contributor

    FWIW I can't reproduce the 40s delay or anything like it (v0.72, Linux, tried on a few different machines).

    Nu currently streams in pages of 1000 records each, so maybe it's getting stuck somewhere in your first 1000 files...

    edit: I can reproduce this on Windows. Taking a look....

  17. rgwood commented on Dec 9, 2022

    @rgwood
    Contributor

    OK, I can reproduce this on Windows - there is a delay of 5-10s before getting any results from ls **/* when called in my home directory. If I profile nu -c "cd ~; ls **/* | first 20" in Superluminal, I can see that a tremendous amount of time is spent in std::sys::windows::fs::metadata:

    image

    From what I can tell, Nu is spending that time gathering file metadata for a lot of files instead of just the first 20. This doesn't quite fit my understanding of how Nu's iterators/streams work, so my understanding of them is probably wrong.

  18. rgwood commented on Dec 9, 2022

    @rgwood
    Contributor

    Alright, my current rough understanding:

    • for a pattern like **/*, nu_glob can look at many files before returning a result
    • for each of those files, nu_glob needs to check file metadata using fs::metadata
    • that file metadata call is relatively slow on Windows (as expected)

    Not easy to improve without a deep dive into the globbing code. I'm going to leave this here for now.

  19. added
    A:streaming
    on Dec 23, 2022
  20. added
    A:glob
    on Jul 9, 2023
  21. cosineblast commented on Dec 18, 2024

    @cosineblast
    Contributor

    I can note a smaller-scale version of this problem even on linux. Having more than 90k files in a directory makes so that ls **/* takes at least 500 milliseconds to produce any results.

    image

    Although it takes less than one-second, it is still annoying with things like fzf, specially since the cold start scales linearly with the number of files under your home directory.

  22. added a commit that references this issue on Dec 25, 2024
    81baf53
  23. added this to the v0.102.0 milestone on Dec 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A:globA:streamingdelightperformancepolish

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions