Ticket #2836 (new enhancement)

Opened 12 years ago

Last modified 10 years ago

Faster directory load in certain (specific) cases

Reported by: gotar Owned by:
Priority: major Milestone: Future Releases
Component: mc-core Version: master
Keywords: Cc:
Blocked By: Blocking:
Branch state: no branch Votes for changeset:

Description

If there's a need to enter directory containing thousands of entries, calling lstat() for every one of them is very expensive ...and sometimes not necessary. My suggestion:

  1. make use of AC_STRUCT_DIRENT_D_TYPE to check for dirent.d_type existence for the rest to work at all,
  2. if:
    • user has set some new option (like 'quick_cd' to be >0),
    • current panel view doesn't include UID/GID/mode/*time etc. (higher levels of 'quick_cd' may further narrow it down, I think quick_cd=1 should strip on size only, 2 for size and *time, and 3 ignore all the attributes),
  3. then:
    • handle_dirent() for d_type==DT_DIR should skip mc_lstat(), instead put some predefined values (0s) when called from do_load_dir(),
    • keep it as it is for do_reload_dir(),
  4. alt-t for such partial directory listing should reload directory when required (if some not loaded attrs need to be displayed).

This way quick_cd=1 omits lstat() for directories, when current panel view requests type/name/size - only size is lost and this is usually useless (and fast to retrieve via ctrl-space). With higher levels one can expand this behaviour up to entirely disabling lstat() for directories. Still, ctrl-r would bring all the data back.

Change History

comment:1 Changed 10 years ago by gotar

It could do even better in general (without any extra option) - when panel is sorted by name, mc_lstat() might be called only for visible files (unless already loaded).

Note: See TracTickets for help on using tickets.