[BuildStream] [Performance] Caching composited state



Hi all,

In my efforts to reduce the work we do at load time (for loads beyond
the initial load of a project) I am now starting to look at what we can
do to cache the results of compositing data for elements.  This is the
first step along the way to potentially caching the element graph longer
term.

To get started on this, I am looking at what it will take to migrate a
lot of the work currently done in Element.__init__ and Source.__init__
into the loader.  For example, constructing plugin defaults, compositing
variables, public data, etc, doesn't actually need the element instances.

My rough plan of action for this is:

1. Make as much of Element.__init__ and Source.__init__ be @classmethod
   or @staticmethod as I possibly can.  Submit this as an MR (or two)
   whose sole purpose it is to clarify the data flow through these
   routines.
2. Migrate that work from Element and Source into Loader, MetaElement,
   or MetaSource as appropriate.
3. Repeat 1 and 2 for Project where it makes sense to (though Project is
   composited once and so is pretty cheap to not cache so long as we can
   trace it)
4. Attempt to rework composition so that it isn't an in-place mutation
   but rather treats both of its inputs as immutable.
5. Add in a mechanism for a Node to have an identity (hash of content perhaps?)
   which will allow us to say "if I compose X onto Y I get Z" as a meaningful
   thing to allow us to cache (X.identity,Y.identity) => Z
6. Go from there toward not having to compute Z if we already have and know the
   two input identities and have a cache.

Even if we don't end up caching between runs of `bst`, my expectation is that
the above will yield speedups merely because many elements in a project end up
composing the same things as other elements already did, thus wasting "work".

I welcome any input/ideas regarding the above, I hope to get the first MR
related to step one up by the end of the week.

D.

-- 
Daniel Silverstone                          https://www.codethink.co.uk/
Solutions Architect               GPG 4096/R Key Id: 3CCE BABE 206C 3B69


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]