GNOME Bugzilla – Bug 160531
startup takes ages
Last modified: 2005-02-03 09:02:33 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.
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 :)
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.
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.
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,
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.
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.
Created attachment 36602 [details] [review] Proposed patch
*** Bug 165397 has been marked as a duplicate of this bug. ***
Should definitely be looked at for 2.10 IMO.
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?
The patch looks good to me, but I will test it this afternoon.
*** Bug 164624 has been marked as a duplicate of this bug. ***
markmc's patch seems to work with all my test cases for ggv. I applied the patch to recent-files in ggv.
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.