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 520468 - Add a Env to enable/disable scan_and_update_registry for usage on embedded
Add a Env to enable/disable scan_and_update_registry for usage on embedded
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
0.10.17
Other Linux
: Normal enhancement
: 0.10.20
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2008-03-05 07:53 UTC by Jason Zhao
Modified: 2008-04-26 00:27 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gst.c patch (3.44 KB, patch)
2008-03-05 07:54 UTC, Jason Zhao
none Details | Review
gst.c patch (3.49 KB, patch)
2008-03-07 08:51 UTC, Jason Zhao
accepted-commit_after_freeze Details | Review
new patch with "-is_enable and _set_enable" (5.06 KB, patch)
2008-03-21 05:43 UTC, Jason Zhao
none Details | Review
latest gst.c patch (5.85 KB, patch)
2008-03-24 06:46 UTC, Jason Zhao
none Details | Review
gstreamer-sections.txt patch (412 bytes, patch)
2008-03-24 06:47 UTC, Jason Zhao
none Details | Review
running.xml patch (538 bytes, patch)
2008-03-24 06:47 UTC, Jason Zhao
committed Details | Review
gst.c patch with removing API (4.87 KB, patch)
2008-04-02 01:58 UTC, Jason Zhao
needs-work Details | Review
gst.c patch updated with stefan's review (5.26 KB, patch)
2008-04-24 03:06 UTC, Jason Zhao
committed Details | Review

Description Jason Zhao 2008-03-05 07:53:31 UTC
Add a Env to enable/disable scan_and_update_registry for usage on embedded.

Env name is GST_REGISTRY_UPDATE, if set it as "no", gstreamer will not do updation for registry file when initialize.

Changed files:
gst/gst.c

Motorola would like to contribute Gstreamer patch to the  Gstreamer open source
community project. Please find attached the patch applicable for Gstreamer. For
any questions, please feel free to contact (Zhao Liang "e3423c@motorola.com",
Shi Ling "w20230@motorola.com").
Comment 1 Jason Zhao 2008-03-05 07:54:26 UTC
Created attachment 106603 [details] [review]
gst.c patch
Comment 2 Jason Zhao 2008-03-07 08:51:13 UTC
Created attachment 106761 [details] [review]
gst.c patch
Comment 3 Julien MOUTTE 2008-03-20 09:59:09 UTC
The patch looks ok to me.

Can we have a second validation before we commit ?
Comment 4 Michael Smith 2008-03-20 10:15:40 UTC
Looks ok to me. I haven't applied it or tested it, though.

Did you do that? If so, looks ok to commit after the current freeze.
Comment 5 Wim Taymans 2008-03-20 10:24:09 UTC
seems ok and seems to work for me.
Comment 6 Wim Taymans 2008-03-20 10:25:04 UTC
oh, it did not compile, I had to fix it to const gchar *update_env;
Comment 7 Tim-Philipp Müller 2008-03-20 10:34:11 UTC
If this is in fact useful and we want to support it, then we should IMHO also add proper _is_enabled() _set_enabled() functions rather than just rely on an environment variable.

It seems to me this is more something you'd want to hard-code in embedded applications and not so much something you'd want to be able to sometimes enable and sometimes disable for debugging purposes like the segtrap and registry fork stuff.
Comment 8 Tim-Philipp Müller 2008-03-20 10:52:16 UTC
(didn't mean to change milestone and patch status)
Comment 9 Stefan Sauer (gstreamer, gtkdoc dev) 2008-03-20 18:02:49 UTC
I wonder if this is the way to do it. Shouldn't there be a configure switch to turn off registry checking by default and only scan if the env-var is set. Nothing would change for normal installations. Where this is used, one can run GST_REGISTRY_UPDATE=1 gst-inspect >/dev/null 2>&1 after installations or during boot-time.

Also the new env-var should be documented in the man-pages.
Comment 10 Jason Zhao 2008-03-21 02:27:05 UTC
The default is yes for GST_REGISTRY_UPDATE, so I think it will not impact current implementation, and adding _is_enabled() _set_enabled() functions is good idea for convenience.

I will try to get another fix verson for Tim's proposal.
Comment 11 Jason Zhao 2008-03-21 05:43:01 UTC
Created attachment 107725 [details] [review]
new patch with "-is_enable and _set_enable"
Comment 12 Stefan Sauer (gstreamer, gtkdoc dev) 2008-03-21 20:51:44 UTC
I would still make this a build option (via configure). I am not seeing a usecase for _is_enabled() _set_enabled() functions. If I do _set_enabled(TRUE) nothing will happen, as the registry is only checked at startup.

If people want it, then when committing the patch please also add the new env-var to the docs and update docs/gst/gstreamer-section.txt with the new API.
Comment 13 René Stadler 2008-03-23 00:41:28 UTC
If this should go in, please don't make the variable be called GST_REGISTRY_UPDATE with default yes/1.  It should be called GST_DISABLE_REGISTRY_UPDATE with default being unset (meaning off) instead.  This makes more sense and is consistent with the other GST_DISABLE_*/--gst-disable-* options.
Comment 14 Jason Zhao 2008-03-24 06:45:55 UTC
I have updated my patch, add "--gst-disable-registry-update" in init option, env-var to running.xml and API to gstreamer-sections.txt

For environment name, I find there are no such environment name as "GST_DISABLE_*", so I think GST_REGISTRY_UPDATE is reasonable just like GST_REGISTRY_FORK. 

For the usecase of "_set_enabled()", I am not sure whether it is correct that user can call it before gst_init(), or we may remove these functions ?

Changed files:
gst.c
doc/gst/running.xml
doc/gst/gstreamer-section.txt
Comment 15 Jason Zhao 2008-03-24 06:46:47 UTC
Created attachment 107896 [details] [review]
latest gst.c patch
Comment 16 Jason Zhao 2008-03-24 06:47:21 UTC
Created attachment 107897 [details] [review]
gstreamer-sections.txt patch
Comment 17 Jason Zhao 2008-03-24 06:47:46 UTC
Created attachment 107898 [details] [review]
running.xml patch
Comment 18 Stefan Sauer (gstreamer, gtkdoc dev) 2008-03-31 08:27:06 UTC
jason, could you do some before/after meassurements? I modified logging slightly and looked at the numbers. On x86 the reading of the cache takes 1/10 of a second. Verification that the cache is still good, takes 1/100 of a second. I don't think its worth to optimize that. I have committed a small optimization on cache validation and will try another one still. But I recommend looking at optimizing reading the cache. Bug #359653 has some hints in comment #26 and comment #35.

$ GST_DEBUG="GST_INIT:3" gst-inspect --gst-disable-registry-fork >/dev/null
0:00:00.005030537 gst.c:753:ensure_current_registry_nonforking: ...
0:00:00.094529159 gst.c:659:scan_and_update_registry: Validating registry cache
0:00:00.102749110 gst.c:723:scan_and_update_registry: Registry cache has not changed
Comment 19 Jason Zhao 2008-03-31 08:48:50 UTC
Stefan, I think it is good for PC, but on embedded, both cpu and storage speed are slow, and the scan_and_update time is increasing line with the plugin number. 
By my test on embedded, if our plugin number is about 20, it will cost 200 ms, and app will do it every time launch. I think it is not necessary on embedded, as it may not change the plugins frequently.

By the way, if optimizing reading the cache can improve the performance, it is  really a good idea.
Comment 20 Julien MOUTTE 2008-04-01 10:44:02 UTC
So current situation on this bug is that registry update is enabled by default except if launched with --gst-disable-registry-update or the GST_DISABLE_REGISTRY_UPDATE env var set.

I think that the function set to enable disable is not really useful in that case.

Can we commit ?
Comment 21 Stefan Sauer (gstreamer, gtkdoc dev) 2008-04-01 10:52:25 UTC
Just for the record on Nokia N810:
0:00:00.101044000  gst.c:767:ensure_current_registry_nonforking: 
0:00:00.288879000  gst.c:737:scan_and_update_registry: Registry cache has not
changed

So its about 2/100 sec. which is still quite fast.
The opne optimization I tried did not work out. I am basically fine with
committing it. I still wonder whats the usecase for the API, Tim?
Comment 22 Stefan Sauer (gstreamer, gtkdoc dev) 2008-04-01 12:15:38 UTC
< ensonic> __tim: what use case where you thinking of when suggesting to add _is_enabled() _set_enabled() to the registry-no-checking patch
< __tim> ensonic: use case "call this before gst_init to disable registry update checking"
< __tim> Having a magic environment variable for this doesn't seem quite right to me 
< ensonic> __tim: imho the usecase is to have it disabled by default and just run GST_CHECK_REGISTRY_CACHE=1 gst-inspect >/dev/null at startup and after installs
< __tim> true, and some have setters and getters as well, e.g. gst_registry_fork_set_enabled() and gst_segtrap_is_enabled()
< ensonic> __tim: instead of an env-var it could lso be an option
< __tim> but I don't really care enough to argue about this at length to be honest ;)
< ensonic> __tim: I prefer and option over two extra API entries that would be hardly called

so lets use an option, unless someone has a usecase for apps, the API can be added later if needed.
Comment 23 Jason Zhao 2008-04-02 01:44:44 UTC
Stefan, if use gstreamer as ringtone engine, it will have critial performance issue, as ringtone engine needs start playback rapidly (less than 300ms), if we spend 200ms in gst_init(), we will not match the goal.

And if this patch doesn't impact the current behavior, and it can also improve the startup performance, why not add it?

For new API(set/get), I also think it is not useful, I will try to remove it.
Comment 24 Jason Zhao 2008-04-02 01:58:42 UTC
Created attachment 108450 [details] [review]
gst.c patch with removing API
Comment 25 Stefan Sauer (gstreamer, gtkdoc dev) 2008-04-23 12:31:10 UTC
jason the patch is missing the Gobject entry for the option:

see gstc:gst_init_get_option_group()

    {"gst-disable-registry-update", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
          (gpointer) parse_goption_arg,
          N_("Disable updating the registry"),
        NULL},

you can verift by running e.g. gst-launch-0.10 --help-gst
and it should show:
--gst-disable-registry-update     Disable updating the registry
Comment 26 Stefan Sauer (gstreamer, gtkdoc dev) 2008-04-23 12:39:33 UTC
Besides the GOption stuff this works fine and I am +1 to commit it. jason, thanks for the works on it.
Comment 27 Jason Zhao 2008-04-24 02:50:08 UTC
Stefan, thanks for your suggestion, I will update my patch and add the missed.
Comment 28 Jason Zhao 2008-04-24 03:06:19 UTC
Created attachment 109796 [details] [review]
gst.c patch updated with stefan's review
Comment 29 Stefan Sauer (gstreamer, gtkdoc dev) 2008-04-24 07:02:48 UTC
This looks good now. Before committing, I would just reorder the goption, so that its before "gst-disable-registry-fork" (as it is in the other lsts).

Anyone also fine with it?
Comment 30 Stefan Sauer (gstreamer, gtkdoc dev) 2008-04-24 14:42:17 UTC
I was just about to commit it, but while looking at it once again I would like to confirm one detail with the ther developers.

ensure_current_registry() is now  doing
#ifdef USE_BINARY_REGISTRY
  gst_registry_binary_read_cache (default_registry, registry_file);
#else
  gst_registry_xml_read_cache (default_registry, registry_file);
#endif

while this code was in
ensure_current_registry_forking/nonforking()

My question: should the forking cover registry cache loading *and* plugin loading or is plugin loading enough.
Comment 31 Stefan Sauer (gstreamer, gtkdoc dev) 2008-04-24 15:14:52 UTC
2008-04-24  Stefan Kost  <ensonic@users.sf.net>

	patch by: Jason Zhao <e3423c@motorola.com>

	* docs/gst/running.xml:
	* gst/gst.c:
	  Enable/disable scan_and_update_registry() based on commandline switch
	  or environment variable. Fixes #520468.
Comment 32 Jason Zhao 2008-04-25 01:36:56 UTC
Stefan, your question may be our further optimizatiin goal. 
Comment 33 Stefan Sauer (gstreamer, gtkdoc dev) 2008-04-25 06:40:37 UTC
jason, I misread the code. The registry reading was actualy before the fork. So you change to move it to ensure_current_registry() is also a nice cleanup to have this just in one place.
Comment 34 Jason Zhao 2008-04-25 06:44:46 UTC
Yes, but if registry is big, adding registry reading into fork process is also a good idea. How about it?
Comment 35 Stefan Sauer (gstreamer, gtkdoc dev) 2008-04-25 08:21:50 UTC
Jason, look at Bug #359653. It outlines some ideas how to make registry reading as such faster. I haven't had time to start implementing it though.

The fork() won't help to make things faster, as the parent waits for the child to finish checking the registry and in case of changes re-read it.
Comment 36 Jason Zhao 2008-04-25 08:58:49 UTC
stefan, Is it possible to do registry reading at forked background process?
Comment 37 Stefan Sauer (gstreamer, gtkdoc dev) 2008-04-25 09:10:56 UTC
Well, it is done by default if your platform has fork() and you don't pass --gst-disable-registry-fork. But ensure_current_registry_forking() wait for the child-process to finish.

As far as I know, you can't initialize the libs totally async. I would be nice to have a set of threads doing gst_init(), gtk_init() and so on and then wiat for all of them to join. But imho that would not work.
Comment 38 Jason Zhao 2008-04-25 09:20:13 UTC
Stefan, thanks for your warmhearted answer.
Comment 39 Jan Schmidt 2008-04-26 00:27:07 UTC
Try to put all of gst_init() in a background thread sounds painful to me - but possible, and without changing GStreamer itself.... just all the applications, heh.

An approach I've thought of before would be to make gst_init() spawn a thread for registry reading and instrumenting all the entry points to the gst_registry_* with a _priv_gst_registry_wait_loaded()... so that the registry loading occurs asynchronously and the program can continue without blocking until the first time it actually tries to look at plugin features or create an element.

It doesn't work if anything accesses the GstRegistry stuff directly though - everyone would need to go through the API