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 160531 - startup takes ages
startup takes ages
Status: RESOLVED FIXED
Product: libegg
Classification: Other
Component: recent-files
unspecified
Other All
: Urgent blocker
: ---
Assigned To: James Willcox
James Willcox
: 164624 165397 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2004-12-05 20:18 UTC by Jaka Mocnik
Modified: 2005-02-03 09:02 UTC
See Also:
GNOME target: 2.10.0
GNOME version: 2.9/2.10


Attachments
Proposed patch (1.69 KB, patch)
2005-01-27 16:10 UTC, Thomas Wood
none Details | Review
another way (2.05 KB, patch)
2005-01-31 09:44 UTC, Mark McLoughlin
none Details | Review

Description Jaka Mocnik 2004-12-05 20:18:35 UTC
checkout ggv (probably any other recent-files using application will do), update
its copy of src/recent-files with CVS HEAD version of recent-files, build,
install, make sure you have a fairly large .recently-used file (304 items in
mine, 3 with a HTTP uri, this might be important, because recent-files/gnome-vfs
may be using the network to access these files) and start the newly built ggv.
it takes 20 seconds for the app to startup, as opposed to a second or two, which
is what it takes with the recent-files in CVS HEAD of ggv, which is from August.
Comment 1 Tommi Komulainen 2004-12-23 18:46:57 UTC
I'm pretty sure it's the HTTP URIs (or any remote URI for that matter)

There's an odd difference between egg_recent_item_new_from_uri() and
egg_recent_item_set_uri() -- the former sets the MIME type to 'unknown' while
set_uri() will result in a call to gnome_vfs_get_mime_type() if the item does
not have the MIME type explicitly set.

<URI> is before <Mime-Type> in the xml so set_uri() is guaranteed to be called
before the MIME type gets explicitly set a few tags later so it's always going
to do the MIME type lookup from remote server.  I think it's also throwing away
the (expensive) result because it gets overwritten from the <Mime-Type> tag soon
after.

Now, someone actually familiar with the code should probably have a closer look :)
Comment 2 Ross Burton 2005-01-07 13:54:57 UTC
This test should be re-run with an updated libegg from after 9th January, as
there was a bug which resulted in hundreds of g_warning() calls.  These would
need to be written somewhere and would contribute to a slowdown, though I doubt
it would make that much of a difference.
Comment 3 Tommi Komulainen 2005-01-07 14:29:38 UTC
I was observing the slowdown with only the explicit-mime-type bits backported
and there were no g_warnings.  I think gnome_vfs_get_mime_type() should never be
called for remote files, even if they are lacking the MIME type, when parsing
the xml file.
Comment 4 Paolo Maggi 2005-01-11 22:41:11 UTC
I have observed this one to in gedit when I have copied tha current CVS HEAD
version.
I have fixed this problem in gedit.
This bug is due to the fact that after the markmc patch about bug #154765, when
reading the model from disk, gnome_vfs_get_mime_type() is called for each file
in the ~/.recently-used. In fact, egg_recent_model normally calls
egg_recent_item_set_uri before egg_recent_item_set_mime is called.
Being mime_type_is_explicit == FALSE for all the newly created items,
gnome_vfs_get_mime_type() is always called.

My patch tries to fix this problem without removing the explicit-mime-type
feature using a little trick (i.e. setting mime_type_is_explicit to TRUE before
calling egg_recent_item_set_uri and resetting it after the call).

Here the patch:

Index: egg-recent-model.c
===================================================================
RCS file: /cvs/gnome/gedit/gedit/recent-files/egg-recent-model.c,v
retrieving revision 1.18
diff -u -p -r1.18 egg-recent-model.c
--- egg-recent-model.c  10 Jan 2005 18:25:53 -0000      1.18
+++ egg-recent-model.c  11 Jan 2005 22:38:11 -0000
@@ -392,6 +392,12 @@ end_element_handler (GMarkupParseContext

        switch (peek_state (info)) {
                case STATE_RECENT_ITEM:
+                       if ((info->current_item->mime_type == NULL) &&
+                           !info->current_item->mime_type_is_explicit)
+                       {
+                               egg_recent_item_set_mime_type
(info->current_item, NULL);
+                       }
+
                        info->items = g_list_append (info->items,
                                                    info->current_item);
                        if (info->current_item->uri == NULL ||
@@ -422,7 +428,17 @@ text_handler (GMarkupParseContext *conte
                case STATE_GROUPS:
                break;
                case STATE_URI:
-                       egg_recent_item_set_uri (info->current_item, text);
+               {
+                       if ((info->current_item->mime_type == NULL) &&
+                           !info->current_item->mime_type_is_explicit)
+                       {
+                               info->current_item->mime_type_is_explicit = TRUE;
+                               egg_recent_item_set_uri (info->current_item, text);
+                               info->current_item->mime_type_is_explicit = FALSE;
+                       }
+                       else
+                               egg_recent_item_set_uri (info->current_item, text);
+               }
                break;
                case STATE_MIME_TYPE:
                        egg_recent_item_set_mime_type (info->current_item,

Comment 5 Paolo Maggi 2005-01-21 13:34:22 UTC
snorp: markmc: could you please review the patch I attached. I think it is very
important to fix the main copy of libegg in time for GNOME 2.10. Otherwise all
GNOME applications using current copy will have unacceptable startup time.
I know it is a bit tricky, but it solves the problem and if it is needed we
could rewrite it in a less tricky way.
Comment 6 Thomas Wood 2005-01-27 16:07:58 UTC
I recently stumbled across this bug since every time I ran gnome-panel (i.e.
each startup) with a gnome menu applet on. I got asked for my ssh passphrase
because of ssh:// items in the Recent Documents menu. I applied the above patch
and it resolved the issue. I will attach the patch I used.
Comment 7 Thomas Wood 2005-01-27 16:10:47 UTC
Created attachment 36602 [details] [review]
Proposed patch
Comment 8 Vincent Untz 2005-01-28 00:54:57 UTC
*** Bug 165397 has been marked as a duplicate of this bug. ***
Comment 9 Kjartan Maraas 2005-01-30 18:43:43 UTC
Should definitely be looked at for 2.10 IMO.
Comment 10 Mark McLoughlin 2005-01-31 09:44:34 UTC
Created attachment 36754 [details] [review]
another way

I wonder if this is a better way of fixing both this and bug #154765? Only
lookup the mime type when egg_recent_item_get_mime_type() is called?
Comment 11 Paolo Maggi 2005-01-31 10:36:57 UTC
The patch looks good to me, but I will test it this afternoon.
Comment 12 Jaka Mocnik 2005-02-02 18:28:19 UTC
*** Bug 164624 has been marked as a duplicate of this bug. ***
Comment 13 Jaka Mocnik 2005-02-02 21:06:14 UTC
markmc's patch seems to work with all my test cases for ggv. I applied the patch
to recent-files in ggv.
Comment 14 Mark McLoughlin 2005-02-03 09:02:33 UTC
Okay, committed:

2005-02-03  Mark McLoughlin  <mark@skynet.ie>

        Fix problem where we tried to detect the MIME type of
        recent items before EggRecentModel could set it
        explicitly. Was causing very slow startup for some
        apps. See bug #160531

        * libegg/recent-files/egg-recent-item.[ch]:
        (egg_recent_item_set_uri),
        (egg_recent_item_set_mime_type): don't call update_mime_type()
        here.
        (egg_recent_item_get_mime_type): call it here instead.