Ticket #3662 (closed defect: invalid)

Opened 8 years ago

Last modified 8 years ago

MC is very slow when starting and changing directories on Windows 10

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

Description

I'm using midnight commander with Cygwin 64 bit on Windows 10 64 bit.

After moving to a new machine and a clean reinstall of windows and Cygwin, my Midnight Commander started to get very laggy - starting mc, any change of directory or exiting from finding files (to refresh list of files in the two panes) takes long seconds. Restarting doesn't help.

I have no idea what could be the reason for these hiccups. MC normally works fine: arrow presses work well, viewing and editing is instant, I can autocomplete paths on the command line with no lag.

But this one thing takes up to 10 seconds - changing directories. Searching in files has a similar lag, but only once (ie not in every chdir it could have done). In non-mc Cygwin usage this issue doesn't happen.

The task manager doesn't show any abnormally high CPU or memory usage on any process. I have cygserver running, using bash as my shell and have no fancy PS1 settings, my $CYGWIN is only winsymlinks:native.

I'm dealing with this issue for some time now and it really impedes my work. If you need me to run some other tests or need any more info from me, please ask and I'll do what I can. This question has already been asked on SuperUser? (http://superuser.com/questions/1097601/midnight-commander-sometimes-very-slow) and Cygwin mailing list.

My environment

  • Windows 10 pro 64 bit, up to date
  • Not connected to a domain, no network drives
  • No anti virus software apart from the one built in Windows
  • Two hard drives (system on SSD (C:), D: is a SSHD), quite a few directory junctions from C: to C:, no loops
  • I'm usually using fatty as the terminal, but mintty has the same issues
  • GNU Midnight Commander 4.8.17
  • cygserver is installed
$ LC_MESSAGES=C mc -V
GNU Midnight Commander 4.8.17
Built with GLib 2.46.2
Using the ncursesw library
With builtin Editor
With subshell support as default
With support for background operations
With mouse support on xterm
With support for X11 events
With internationalization support
With multiple codepages support
Virtual File Systems: cpiofs, tarfs, sfs, extfs, ext2undelfs, ftpfs, sftpfs, fish
Data types: char: 8; int: 32; long: 64; void *: 64; size_t: 64; off_t: 64;
$ LC_MESSAGES=C mc -F
Root directory: /cygdrive/c/Users/chanibal

[System data]
    Config directory: /etc/mc/
    Data directory:   /usr/share/mc/
    File extension handlers: /usr/libexec/mc/ext.d/
    VFS plugins and scripts: /usr/libexec/mc/
        extfs.d:        /usr/libexec/mc/extfs.d/
        fish:           /usr/libexec/mc/fish/

[User data]
    Config directory: /cygdrive/c/Users/chanibal/.config/mc/
    Data directory:   /cygdrive/c/Users/chanibal/.local/share/mc/
        skins:          /cygdrive/c/Users/chanibal/.local/share/mc/skins/
        extfs.d:        /cygdrive/c/Users/chanibal/.local/share/mc/extfs.d/
        fish:           /cygdrive/c/Users/chanibal/.local/share/mc/fish/
        mcedit macros:  /cygdrive/c/Users/chanibal/.local/share/mc/mc.macros
        mcedit external macros: /cygdrive/c/Users/chanibal/.local/share/mc/mcedit/macros.d/macro.*
    Cache directory:  /cygdrive/c/Users/chanibal/.cache/mc/

strace log

Here is a strace log, maybe someone has an idea what did go wrong?
http://pastebin.pl/view/9b839815
(recorded with LOCALE=C strace -q -o /tmp/mc-log mc /tmp)

In the recorded session I have:

  • started mc in /tmp directory
  • entered /tmp/NVIDIA Corporation directory
  • went back up (..)
  • entered /tmp/mc-chanibal directory
  • went back up (..)
  • exited with F10

You can see that normalize_posix_path takes a lot of time, but trying
to force the same call with cygpath fails to take so long (more
later).

Additional timing information

TL;DR: probably not Cygwin's fault.

A find of all directories in my $HOME takes 4.6 seconds:

$ time find ~ -type d | wc -l
(snipped two directories without permissions)
19919

real 0m4.626s
user 0m0.796s
sys 0m3.765s


A ls -al on all of these 19919 directories took a lot of time, but
the average was fairly low:

time (find ~ -type d | while read f; do { time ls -al $f; } \

|& awk '$1 == "real" { printf $2 }' \
| awk -Fm '{printf( "%2.4f", $1 * 60 + $2 )}'; \
echo -e "\t$f"; done \

) >/tmp/ls-time-log ;
(snipped two dirs without permissions)

real 12m21.870s
user 7m4.576s
sys 16m34.446s

The average time to do an ls -al is 0.020s, min is 0.017, max is 0.154:

$ awk 'BEGIN { sum=0; min=9999; max=0; minf=""; maxf=""; } \

$1 { sum += $1; \

if(min > $1) { min = $1; minf = $2; }; \
if(max < $1) { max = $1; maxf = $2; } } \

END { print "avg: " sum/NR; print "min: " min " " \

minf; print "max: " max " " maxf }' </tmp/ls-time-log

avg: 0.0204292
min: 0.0170 /cygdrive/c/Users/chanibal/AppData/Roaming/OculusClient/Local
max: 0.1540

/cygdrive/c/Users/chanibal/AppData/Local/Android/sdk/platforms/android-23/data/res/drawable-hdpi

With the overhead of measuring time it averages 16m34s/19919 = 0.499s
per call to ls -al, two awks and a iteration of find. Not very
good, but not four seconds.


Normalizing with cygpath doesn't take long:

$ time strace cygpath -aw /tmp/NVIDIA\ Corporation/ | grep

normalize_posix_path

116 11175 [main] cygpath 3524 normalize_posix_path: src

/tmp/NVIDIA Corporation/

20 11195 [main] cygpath 3524 normalize_posix_path:

/tmp/NVIDIA Corporation/ = normalize_posix_path (/tmp/NVIDIA
Corporation/)

real 0m0.034s
user 0m0.015s
sys 0m0.000s

Other Midnight Commander builds

I have also tried the unofficial mc build for windows that does not use cygwin and build my own mc from current master at github. This issue persisted.

Change History

comment:1 Changed 8 years ago by chanibal

Started using LFM/cygwin because of this bug. It does not exhibit this behavior either, so again probably MC's bug.

Please let me remove alias mc=lfm from my ~/.profile soon :(

comment:2 Changed 8 years ago by andrew_b

Why do you want MC under Cygwin under Windows?.
Use Far Manager instead. It is free and open.

Sorry, but none of MC developers uses MS Win. Windows is not supported.

Apparently, wontfix.

Version 0, edited 8 years ago by andrew_b (next)

comment:3 Changed 8 years ago by chanibal

Because after 10+ years of MC usage I've grown quite attached to it. Plus it did work pretty well on Windows 10 and earlier 8.1 for more than a year. Nothing enables me to search through file

Far doesn't work with Cygwin well. Other tools like LFM do, but still it's not MC.

If none of the MC devs have access to Windows then maybe they'd give some pointers on where to search for the issue, and I might be able to do it myself.

comment:4 follow-up: ↓ 5 Changed 8 years ago by chanibal

I have found the issue and decided it's Windows 10 or faulty hardware fault, not MC. Midnight commander does trigger this issue, but it does so by using the OS in expected ways, so it's not its fault.

To be exact, the issue is that enumerating devices takes time (exactly 4 or 5 seconds in Windows powershell or 4 seconds in Cygwin). The fix in my case was to disable the DVD drive that was taking time. Details on the Cygwin mailing list thread.

Please close this issue as invalid.

Last edited 8 years ago by chanibal (previous) (diff)

comment:5 in reply to: ↑ 4 Changed 8 years ago by andrew_b

  • Status changed from new to closed
  • Resolution set to invalid
  • Milestone Future Releases deleted

Replying to chanibal:

Please close this issue as invalid.

Ok. Thanks!

Note: See TracTickets for help on using tickets.