Giter Club home page Giter Club logo

Comments (15)

gokcehan avatar gokcehan commented on August 16, 2024

It would indeed be more useful @KenjiTakahashi . There are a few considerations though:

  • There doesn't seem to be a way to get the item count in a directory without reading all entries. In crowded directories this may take some time.
  • lf displays information for all columns including the preview and parent directories which is different than ranger. So this is the same consideration as above except that we need to do the same thing for two levels instead of one.

To be honest I haven't tried this so I don't know how expensive these operations would be. If we do this though it is a good idea to buffer the information so we don't have to read the directory again when opening a directory. This needs some restructuring in the code. I have a few things in my mind before I can take a look at this.

Sorry for being a little uptight about performance. I frequently need to work with folders having zillions of entries on a disk with a significant latency so I try to avoid anything that may be a performance hog.

from lf.

KenjiTakahashi avatar KenjiTakahashi commented on August 16, 2024

Oh, I did not realise that info is displayed for preview as well. That indeed complicates things.
You're right that there is no (generic) way of getting item count, other than reading the contents list. Some FSes do have such metadata, but most don't, mostly because it's redundant from the FS perspective.

The performance consideration is sound. In fact one of main reasons why I'd like to move from ranger is because of speed.

Well, one thing that could always be done is giving option to disable info for preview.
I guess, the best way will probably be to do some profiling. Maybe I'll try to find some time later to do so.

from lf.

gokcehan avatar gokcehan commented on August 16, 2024

@KenjiTakahashi I have added a profiling flag some time ago but since it only measures cpu timings but not io timings I'm not sure if it will show anything relevant here. You can give it a try if you want.

Having this feature as an option is perfectly fine by me. I'm sure in most cases this will not be a performance consideration even with the information shown in preview and other columns. We can discuss whether to enable this by default or not. I would rather have it off by default.

from lf.

KenjiTakahashi avatar KenjiTakahashi commented on August 16, 2024

I've seen :-).

The showinfo setting is disabled by default, right? So I guess this should be off as well.

from lf.

KenjiTakahashi avatar KenjiTakahashi commented on August 16, 2024

I have moved on to implement this. After some thought, I decided that instead of having some hairy option like info dir-count-file-size, etc., it would be better to split it into fileinfo and dirinfo.

Now, I'm working on getting it showed only on specific panel. The most generic way of doing this would be to allow specifying info per panel, but I'm afraid this is significant amount of work and handling corner cases (we'd need a way to describe "dict of slices" in a config, etc.). Personally, I'm fine with something like infoOn "0:1", which says on which panels to show info.

@gokcehan what do you think?

from lf.

gokcehan avatar gokcehan commented on August 16, 2024

@KenjiTakahashi I thought I mentioned this before but maybe not. What I had in mind was a simple boolean option like dircounts or diritems which would semantically mean displaying number of items for directories as the size. Because in a way this is what we are doing, displaying the size of a directory in a different unit, number of items inside instead of raw size on the disk. By the way, I think it is possible to guess the number of items within a directory from its size but most of the time this approximation fails miserably since directory files grow as blocks (4kb on my machine) and even a single block can hold many items.

As for making info optional in some panels, I think it deserves its own issue. Currently number signs in ratios option is not used so maybe instead of adding a separate infoOn option we could use signs to represent info (e.g. set ratios "-1:2:-3" would mean only displaying info in the middle column). This might feel a little weird but it could be nice for sanity checks and keeping the configuration files simple. I feel like even preview option deserves to be integrated in ratios somehow.

For this issue though, I think you can make some assumptions. The most important consideration would be to decide whether or not to display info in preview pane because it will most likely be changing most frequently. For others, I don't think it matters much. If you're displaying info in the current pane you might as well display it in parent folders as well which would only contribute by a constant factor.

from lf.

KenjiTakahashi avatar KenjiTakahashi commented on August 16, 2024

Huh, sorry for such a long delay, some life things have caught my again...

Well, I thought that it might be useful to some to preserve the "raw size" info and as an extension, the ability to display different info for files and dirs (e.g. display both count and raw size for dirs). But personally, I don't have a real life usage argument for that, so I might do it your way instead.

I don't want to do heuristics here, I feel that counts without guaranteed accuracy are not very useful.

Because it is a quite costly operation, I've made it so the counts are only read when the dir is displayed (in printd), as opposed to when they're read (in readdir) and then they are cached in the file structs. So if info for left column is disabled, parent dir counts are only read when user enters it. I've measured that, at least in my usage, the performance hit is much smaller that way.

I agree that actual implementation of optional info can go to separate issue and preview is where the performance hit will probably be the largest.

Maybe if ratios was renamed to something more generic, like layout, it would be less weird? Just a thought.

from lf.

gokcehan avatar gokcehan commented on August 16, 2024

@KenjiTakahashi You sounded like you have done something already. Did you forget to request a pull somehow? I'm just curious, no need to rush in any case :)

from lf.

KenjiTakahashi avatar KenjiTakahashi commented on August 16, 2024

@gokcehan Yes I have, but after the discussion here I decided to make a few changes, I also found one small bug on the way. I plan to open a PR on this sometime later this week, currently I'm away from my main rig on Easter holidays for one more day.

from lf.

avently avatar avently commented on August 16, 2024

@gokcehan is dircounts working for you? For me nothing changed with this option. No counters

from lf.

gokcehan avatar gokcehan commented on August 16, 2024

@avently It is working for me. Make sure to enable size in info option (e.g. set info size). Also note that information is only displayed when the column is wide enough (i.e. more than two times the width of information for now).

from lf.

avently avatar avently commented on August 16, 2024

@gokcehan yes, the "set info size" fixed the situation. Thank you

from lf.

gokcehan avatar gokcehan commented on August 16, 2024

Just so I don't forget, regarding the arbitrary length numbers discussion in the PR, I also realized things are even worse when multiple information is shown and sizes are on the right side (e.g. set info time:size) so I'm more inclined to limit the number of read items to 4 digits and use fixed sized strings as discussed in the PR.

from lf.

gokcehan avatar gokcehan commented on August 16, 2024

Directory counts now show 4 characters at most (999+ when more than a thousand and ? when directory can't be read due to permissions and so on). Closing this issue now.

from lf.

 avatar commented on August 16, 2024

Directory counts now show 4 characters at most (999+ when more than a thousand and ? when directory can't be read due to permissions and so on). Closing this issue now.

Can you elaborate what do you mean by permissions ? I always get ? on dircounts. Permissions of my homedir were always $USER with drwxr-xr-x.

from lf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.