id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	blockedby	blocking	branch_state	votes
4287	Quadratic(?) slowdown on file moves across filesystems	slyfox	andrew_b	"Tried to move firefox build tree from one btrfs subvolume to another on NVMe device. It contained ~2M files. Normally it should take under a minute to relink a few gigabytes. But mc did not not succeed in 1 hour.

Looks like there is a quadratic behavior in file moves related to single list traversal.

Here is the reproducer:

1. create 1M files in a firectory structure (we will create 1000 dirs 1000 files each)
2. put them all in one directory 'd'
3. move this 'd' from one tmpfs to another

Expected behavior: operation should take seconds (rougly the same time it takes to create the directory tree).

Actual behaviour: it takes tens of minutes to move the dir.

Script to build a directory:

{{{#!sh
#!/usr/bin/env bash

# fail on first problem
set -e

echo ""prepating two new tmpfs filesystems: /tmp/tmpfs-src and /tmp/tmpfs-dst""

mkdir /tmp/tmpfs-src
mkdir /tmp/tmpfs-dst

sudo mount -t tmpfs tmpfs /tmp/tmpfs-src
sudo mount -t tmpfs tmpfs /tmp/tmpfs-dst

# allow current user to fiddle with it
sudo chown ${USER} /tmp/tmpfs-src /tmp/tmpfs-dst

echo ""creating 1M files""
# create 1 million empty files
mkdir /tmp/tmpfs-src/d
for d in {1..1000}; do
    mkdir /tmp/tmpfs-src/d/$d
    touch /tmp/tmpfs-src/d/$d/{1..1000}
done

echo ""don't forget cleanup: 'sudo umount /tmp/tmpfs-src; sudo umount /tmp/tmpfs-dst'""
echo ""Now you can run 'mc /tmp/tmpfs-src /tmp/tmpfs-dst' and try to move 'd' directory with F6.""
}}}

Run as:

1. Run '$ prepare_environment.bash'
2. Run 'mc /tmp/tmpfs-src /tmp/tmpfs-dst'
3. Start moving with 'F6' on 'd' dir.
"	defect	closed	major	4.8.28	mc-core	master	fixed					merged	committed-master
