Topic: GParted device refresh speed
Hi,
I was thinking about the speed of device refresh in GParted. If we want to make it faster we first need to know what is taking the time. So i've hacked up this patch. Definitely not for applying upstream. You can get it with:
git -c http.sslverify=false pull https://rockover.homeip.net/cgit/gparted timing-devel1
At the end is the output from my desktop which has a single hard drive, no raid and 15 partitions. Some observations of my data:
A few external commands are very time consuming:
2.1s (mdadm) scanning for software raid.
1.0s (udevadm) udev event waiting.
0.7s (lvm) 3 commands scanning LVM.
Many of the file system specific query commands are executed twice on unmounted file systems, once for the sector usage and once for the label.
There is another second which passes before the execution of udevadm which isn't yet identified.
Few thoughts on ways to mitigate this:
Have a way to identify what to rescan depending on what has changed. For example mount/umount operations only change the busy status of one file system, yet perform a full rescan.
Only execute hardware and software raid scanning and udev waiting on full Refresh Devices, not after completing every operation.
Keep [Ctrl-R] Refresh Devices performing a full rescan to mitigate missing changes performed simultaneously outside GParted, or bugs not scanning for changes initiated in GParted.
Within a single rescan, cache the output of all commands used to query information so subsequent executions can just read the cache.
Change ext2/3/4, and possibly other file systems too, so that they use the same command to query sectors and label to make better use of the command output cache.
Timing data:
0.000000 +0.000000 STOPWATCH_RESET
0.000000 +0.000000 find_supported_filesystems() start
0.006045 +0.006045 execute_command() execute: sh -c btrfs filesystem label --help
0.009035 +0.002990 execute_command() exit status 0
0.009807 +0.000773 execute_command() execute: sh -c ntfslabel --help
0.012314 +0.002506 execute_command() exit status 256
0.012722 +0.000408 find_supported_filesystems() end
0.117900 +0.105178 STOPWATCH_RESET
0.000000 +0.000000 set_devices() start
0.000030 +0.000030 set_devices() refreshing caches ...
0.001112 +0.001082 execute_command() execute: sh -c blkid
0.219075 +0.217963 execute_command() exit status 0
0.219253 +0.000179 execute_command() execute: sh -c dmraid -sa -c
0.324554 +0.105301 execute_command() exit status 256
0.324650 +0.000096 execute_command() execute: sh -c mdadm --examine --scan
2.518364 +2.193714 execute_command() exit status 0
2.518478 +0.000114 execute_command() execute: sh -c lvm vgscan
3.000609 +0.482131 execute_command() exit status 0
3.000677 +0.000068 execute_command() execute: sh -c lvm pvs --config "log{command_names=0}" --nosuffix --noheadings --separator , --units b -o pv_name,pv_size,pv_free,vg_name
3.175259 +0.174581 execute_command() exit status 0
3.175321 +0.000063 execute_command() execute: sh -c lvm pvs --config "log{command_names=0}" --nosuffix --noheadings --separator , --units b -o vg_name,vg_attr,lv_name,lv_attr
3.194622 +0.019300 execute_command() exit status 0
3.194648 +0.000026 set_devices() refreshed caches
3.614523 +0.419875 execute_command() execute: sh -c e2label /dev/sda1
3.617462 +0.002939 execute_command() exit status 0
3.630905 +0.013443 execute_command() execute: sh -c e2label /dev/sda3
3.633605 +0.002700 execute_command() exit status 0
3.645401 +0.011796 execute_command() execute: sh -c e2label /dev/sda5
3.648050 +0.002649 execute_command() exit status 0
3.654722 +0.006672 execute_command() execute: sh -c btrfs filesystem show /dev/sda6
3.897784 +0.243063 execute_command() exit status 0
3.898516 +0.000731 execute_command() execute: sh -c e2label /dev/sda7
3.910383 +0.011867 execute_command() exit status 0
3.910923 +0.000540 execute_command() execute: sh -c e2label /dev/sda8
3.914004 +0.003081 execute_command() exit status 0
3.914488 +0.000483 execute_command() execute: sh -c e2label /dev/sda9
3.926273 +0.011786 execute_command() exit status 0
3.926796 +0.000523 execute_command() execute: sh -c jfs_tune -l /dev/sda10
3.930643 +0.003847 execute_command() exit status 0
3.931600 +0.000957 execute_command() execute: sh -c nilfs-tune -l /dev/sda12
3.950734 +0.019134 execute_command() exit status 0
3.962121 +0.011387 execute_command() execute: sh -c debugreiserfs /dev/sda14
4.013574 +0.051453 execute_command() exit status 0
4.014161 +0.000587 execute_command() execute: sh -c xfs_db -r -c 'label' /dev/sda15
4.073133 +0.058972 execute_command() exit status 0
4.073622 +0.000489 execute_command() execute: sh -c btrfs filesystem show /dev/sda6
4.079587 +0.005965 execute_command() exit status 0
4.079743 +0.000157 execute_command() execute: sh -c dumpe2fs -h /dev/sda7
4.095954 +0.016211 execute_command() exit status 0
4.096129 +0.000175 execute_command() execute: sh -c dumpe2fs -h /dev/sda8
4.119581 +0.023452 execute_command() exit status 0
4.119779 +0.000198 execute_command() execute: sh -c dumpe2fs -h /dev/sda9
4.147974 +0.028195 execute_command() exit status 0
4.148176 +0.000202 execute_command() execute: sh -c echo dm | jfs_debugfs /dev/sda10
4.162963 +0.014787 execute_command() exit status 0
4.163078 +0.000115 execute_command() execute: sh -c nilfs-tune -l /dev/sda12
4.212579 +0.049500 execute_command() exit status 0
4.212791 +0.000212 execute_command() execute: sh -c debugreiserfs /dev/sda14
4.216071 +0.003281 execute_command() exit status 0
4.216204 +0.000133 execute_command() execute: sh -c xfs_db -c 'sb 0' -c 'print blocksize' -c 'print dblocks' -c 'print fdblocks' -r /dev/sda15
4.219917 +0.003713 execute_command() exit status 0
5.238062 +1.018145 execute_command() execute: sh -c udevadm settle --timeout=1
6.241096 +1.003034 execute_command() exit status 256
6.241345 +0.000249 set_devices() end
Thanks,
Mike