After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 166601 - Cache timeout logic in Unix backend is broken
Cache timeout logic in Unix backend is broken
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkFileChooser
2.6.x
Other All
: Normal normal
: Medium fix
Assigned To: gtk-bugs
gtk-bugs
: 167673 302322 307915 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2005-02-07 20:41 UTC by Håkan Lindqvist
Modified: 2005-07-20 00:04 UTC
See Also:
GNOME target: ---
GNOME version: 2.7/2.8


Attachments
Strace of starting gedit, opening open dialog, closing, exiting (125.43 KB, application/x-bzip)
2005-02-07 20:46 UTC, Håkan Lindqvist
  Details
Jimmac's strace (756.08 KB, text/plain)
2005-02-09 19:03 UTC, Federico Mena Quintero
  Details
Laurent's galeon "save as" trace (139.38 KB, text/plain)
2005-03-01 14:57 UTC, Laurent Martelli
  Details
Patch according to Mortens instructions (I hope) (1015 bytes, patch)
2005-04-29 19:03 UTC, Håkan Lindqvist
none Details | Review
Patch for cache timeout bugs (1.43 KB, patch)
2005-04-29 20:07 UTC, Morten Welinder
committed Details | Review

Description Håkan Lindqvist 2005-02-07 20:41:00 UTC
Please describe the problem:
When opening an open/save dialog and there is a large amount of files and
directories in the visible directory, it takes unreasonably long time.

For instance a folder with 2627 files and folders takes about 25 seconds.


Steps to reproduce:
1. Start some application, in my case gedit
2. Click Open
3. Navigate to the big directory
4. Wait........ ;)

Actual results:
It takes a long time.

Expected results:
It should be quick. ;-)

Does this happen every time?
Yes

Other information:
I will attach strace output of my gedit run.
Comment 1 Håkan Lindqvist 2005-02-07 20:46:10 UTC
Created attachment 37122 [details]
Strace of starting gedit, opening open dialog, closing, exiting
Comment 2 Federico Mena Quintero 2005-02-09 18:43:31 UTC
I think I gave you the wrong instructions; sorry about that :(

Could you please do this:

1. Run gedit and figure out its PID
2. strace -f -ttt -p <pid> -o logfile
3. Invoke the File/Open dialog on the folder which takes a long time to load
4. Kill the strace
5. Attach the logfile here.
Comment 3 Federico Mena Quintero 2005-02-09 19:03:27 UTC
Created attachment 37263 [details]
Jimmac's strace

This is from Jimmac running Gimp.  Doing "File/Open" can take a long time;
visiting the same folder from an already-open file chooser is quick.

Grep for "futex" near the end of the file.  It blocks for 70 seconds (!) and
then resumes.  I wonder why that happens only when you pop up the dialog
initially.
Comment 4 Sven Neumann 2005-02-14 22:15:34 UTC
federico said on IRC that he would love to have two things:

 1. a good strace log with timings and threads, both of opening a new file
    chooser and of setting the path in an existing one
    (also, possibly, of remapping an existing one like in the gimp)

 2. a good ltrace to see what calls to gnome-vfs we are doing
Comment 5 Håkan Lindqvist 2005-02-14 22:49:19 UTC
I can not produce this right now, but will try to get this up soon. Sorry for
the delay..,
Comment 6 Federico Mena Quintero 2005-02-18 16:44:21 UTC
*** Bug 167673 has been marked as a duplicate of this bug. ***
Comment 7 Billy Biggs 2005-02-20 03:45:58 UTC
Here is an strace log from my test app on loading my home directory.

  http://vektor.ca/bugs/chooser-log.txt.bz2
Comment 8 Laurent Martelli 2005-03-01 14:44:49 UTC
This file corrupted:  http://vektor.ca/bugs/chooser-log.txt.bz2

laurent@stan:~/tmp$ bunzip2 chooser-log.txt.bz2 

bunzip2: Compressed file ends unexpectedly;
        perhaps it is corrupted?  *Possible* reason follows.
bunzip2: No such file or directory
        Input file = chooser-log.txt.bz2, output file = chooser-log.txt

It is possible that the compressed file(s) have become corrupted.
You can use the -tvv option to test integrity of such files.

You can use the `bzip2recover' program to attempt to recover
data from undamaged sections of corrupted files.

bunzip2: Deleting output file chooser-log.txt, if it exists.


Comment 9 Laurent Martelli 2005-03-01 14:57:57 UTC
Created attachment 38098 [details]
Laurent's galeon "save as" trace

This was generated using Galeon's save as. The default directory to save in was
~/tmp so it's interesting to see that it first tries to open every file in ~/
before processing ~/tmp.

It seems to open the files and read a block, so it's no wonder it's so slow the
1st time.
Comment 10 Laurent Martelli 2005-03-01 15:17:00 UTC
I also ran ltrace like this:

ltrace -f -ttt -p 8355 --library=/usr/lib/libgnomevfs-2.so.0 -o filechooser.ltrace

It only gave this:

8355 1109690103.339839 --- UNKNOWN_SIGNAL (Unknown signal 32) ---
8355 1109690103.340926 --- UNKNOWN_SIGNAL (Unknown signal 32) ---
9101 1109690103.360903 +++ exited (status 0) +++
8355 1109690103.377388 --- SIGCHLD (Child exited) ---
8355 1109690103.393058 gnome_vfs_unescape_string(0x93ffac0, 0, 32, 0x400ea2fc,
0x9103d00) = 0x93014a8
9102 1109690103.394881 +++ exited (status 0) +++
8355 1109690103.394946 --- SIGCHLD (Child exited) ---
8355 1109690103.509866 gnome_vfs_expand_initial_tilde(0x93ffac0, -1, 0, 0, 0) =
0x93a4a10
8355 1109690103.510130 gnome_vfs_expand_initial_tilde(0x93ffac0, -1, 0, 0, 0) =
0x932eee8
8355 1109690103.510231 gnome_vfs_expand_initial_tilde(0x932f078, -1, 0, 0, 0) =
0x9541428
8355 1109690103.513089 gnome_vfs_expand_initial_tilde(0x932eee8, -1, 0, 0, 0) =
0x93a4a10
8355 1109690107.617543 gnome_vfs_mime_application_free(0, 0x8bf30c8, 1,
0x8195850, 0x93c3820) = 0
Comment 11 Laurent Martelli 2005-03-01 16:43:59 UTC
I've been debugging a little and it looks like xdg_mime_get_mime_type_for_file
opens the file if it can't get the mime-type from the file name.

Returning after xdg_mime_get_mime_type_from_file_name() seems to fix the problem
but is not a long term solution.
Comment 12 Billy Biggs 2005-03-01 17:24:36 UTC
The URL above works fine for me to get the log and uncompress it using bunzip2
version 1.0.2.
Comment 13 Matthias Clasen 2005-04-07 02:30:14 UTC
Making any real progress here will likely require to use a 2-phase approach to
mime type detection: while populating the file list, guess the mime type based
only on the filename, and then do whatever mime sniffing is necessary in the
background, updating the icons as we go.
Comment 14 Federico Mena Quintero 2005-04-28 20:07:14 UTC
See also bug #302322 and bug #154394.
Comment 15 Morten Welinder 2005-04-28 20:15:50 UTC
In my case (bug 302322), the annotated trace shows that the mime stuff is *not*
to blame.  It only kicks in once in a while, namely for extensions that are not
recognized.  The culprit is doing everything twice.
Comment 16 Morten Welinder 2005-04-28 20:24:36 UTC
There is a bug in gtk_file_system_unix_get_folder that means that if loading
ends up taking more than 2s, it will likely take a whole lot more than 2s.

Basically, in the case where we assign to ->asof, we should do so *after* filling
in stats and mimes and using a then-current timestamp.  (But note, that we cannot
simply move the assignment down -- it still has to be done under the same
condition.)

Without this change, the cache can be stale from the time it is filled in.
Not good.
Comment 17 Matthias Clasen 2005-04-29 16:06:56 UTC
Morten, why don't you attach a patch instead of writing a long explanation what
needs to change ?
Comment 18 Morten Welinder 2005-04-29 16:18:53 UTC
Because my tree is currently polluted with, among other things, all the
annotation Federico asked me to do for bug 302322...
Comment 19 Manish Singh 2005-04-29 16:21:42 UTC
So, uh, checkout another tree to work on?
Comment 20 Morten Welinder 2005-04-29 16:26:00 UTC
Guys, I'll do it in due time.  (Yosh: no, that'll blow my inode quota.  Yes,
that is so 80ish.)
Comment 21 Håkan Lindqvist 2005-04-29 19:03:46 UTC
Created attachment 45836 [details] [review]
Patch according to Mortens instructions (I hope)

I attach my interpretation of Mortens patch instructions.

Feel free to laugh at me if I completely misunderstood / did something stupid.
:-)
Comment 22 Håkan Lindqvist 2005-04-29 19:23:49 UTC
However, I have noticed that the problem appears to be mostly(?) fixed with gtk
2.6.7 (or some other library upgrade since the bug was reported) even without
any further patches...
Comment 23 Morten Welinder 2005-04-29 20:07:19 UTC
Created attachment 45842 [details] [review]
Patch for cache timeout bugs

The key here is to get a new value of time(NULL) after stat-ing all those
files.	We should also set asof again after re-reading the stat/mime info due
to staleness.
Comment 24 Matthias Clasen 2005-06-09 18:15:28 UTC
*** Bug 302322 has been marked as a duplicate of this bug. ***
Comment 25 Matthias Clasen 2005-06-16 14:48:44 UTC
*** Bug 307915 has been marked as a duplicate of this bug. ***
Comment 26 Morten Welinder 2005-06-21 13:34:54 UTC
Any reason the patch is not going in?  It may not fix all problems, but it
certainly does fix wrong behaviour when the cache times out.
Comment 27 Matthias Clasen 2005-06-23 20:47:14 UTC
2005-06-23  Matthias Clasen  <mclasen@redhat.com>

	* gtk/gtkfilesystemunix.c (gtk_file_system_unix_get_folder): 
	Fix an error in the cache timeout logic.  (#166601, Morten
	Welinder)
Comment 28 Federico Mena Quintero 2005-07-20 00:04:59 UTC
I'm going to change the title of this bug and mark it as fixed.

Performance in the file chooser is a big topic.  I'll start a wiki page to
document the optimization effort there.  I have done some preliminary profiles
and know more or less what's going on.