gio makes GtkFileChooser behave very poorly on large directories
Submitted by Morten Welinder
Link to original bug (#647036)
Description
(I am certain i reported this previously, but it isn't in bugzilla right now. Maybe the bugzilla hickup ate it.)
When a GtkFileChooser is aimed at a large directory, such as /bin, it behaves poorly. New files come dropping in and trying to scroll anywhere is futile.
I blame gio, specifically next_file_helper in glocalfileenumerator.c
This function sorts files by inode. It does this because on some filesystems (such as ext* based on spinning media), stat-ing a large pile of files is better done in inode order. Doing so, however, essentially randomizes the name ordering.
I suggest that the following changes be made:
-
Increase CHUNK_SIZE to (say) 50000 -- something comfortably larger than the largest /bin you can imagine.
-
Sort alphabetically in next_file_helper.
-
Follow the sort by resorting blocks of (say) 256 files by inode.
Steps 1+2 will make files arrive in the file chooser in mostly alphabetical order and it will behave much nice.
Step 3 will retain 99%+ of the speed benefit of inode sorting.