On 5/15/13 3:31 PM, L. David Baron wrote:
On Wednesday 2013-05-15 14:32 -0700, Gregory Szorc wrote:
I think the more compelling use case is service startup. Proper
dependencies should allow us to more intelligently start services on
demand. This should lead to lower resource utilization and faster
startup times. Shutdown times should also speed up if there are
fewer services to shut down.

This is what we do already; we don't create an XPCOM service until
somebody asks for it.  Now, I'm not saying that all of our code is
perfect about not *asking* for the service until it's needed.  But
in many cases that's more trouble than it's worth; there are many
things we know we'll need during startup, and it's not worth the
extra overhead of checking every time if we've already called
getService.

Ahh, I was thinking more of JS services. In this world, your manifest adds an entry to the "app-startup" category and your service receives the "app-startup" notification. It is customary for it to register an observer for a later startup phase and finish initialization then.

Many services also install one shot timers so they don't overburden app init.

Typically if there are service dependencies, you have service A emit a notification and service B then starts upon receiving it. A problem with this model is you can't reliably and/or easily init service B by itself because B doesn't necessary know how to init A.

The current model is essentially a giant domino reaction cascaded from app-startup. I think I'd prefer a "pull based" solution where the first consumer of service B (perhaps it's a timer or an observer if B is frequently-used) tries to grab an instance and this results in service A being instantiated on-demand. This is accomplished via a service management framework of some kind that knows about all services and their dependencies.

This is comparable to how *NIX operating systems initialize. Gecko is currently using System-V style runlevels. But all the new hotness are replacements like sytemd and upstart which explicitly express service dependencies, can start services in parallel and on demand, and are much faster at starting the operating system as a result.
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to