* Bitbake past, present and future [long]
@ 2006-09-26 14:28 Richard Purdie
2006-10-02 13:00 ` Paul Sokolovsky
0 siblings, 1 reply; 3+ messages in thread
From: Richard Purdie @ 2006-09-26 14:28 UTC (permalink / raw)
To: Using the OpenEmbedded metadata to build Linux Distributions,
bitbake-dev
Paul's comments in #oe have highlighted the fact that whilst I and
perhaps some others know where things are going (and have come from), a
lot of things are in my head which isn't perhaps the best place for
them.
History/background
==================
Once upon a time, we didn't do anything with the runtime variables
RDEPENDS, RRECOMMENDS etc. This lead to a lot of duplication within the
metadata because of the two separate namespaces - you'd have have to add
BOOTSTRAP_EXTRA_DEPENDS = "virtual/kernel" and BOOTSTRAP_EXTRA_RDEPENDS
= "kernel-module-uinput". I complained about this and was told by Rene
to shutup, or fix it if it bothered me so much. So I did :) (well, have
attempted to anyway)
Circa bitbake 1.3, I added handling for the RDEPENDS variables so
bitbake could convert RDEPENDS into a set of DEPENDS. This was quite a
painful process, I changed a lot of the way .dev worked and I resolved
95% of the problems encountered. I'm 100% certain this process was
essential to allow OE to evolve. The end result was the modern neat
looking task packages and the removal of all the add to RDEPENDS and
make sure something equivalent is added to DEPENDS logic in .dev. I
don't think anyone can look at what was there before, look at what there
is now and not say it was an improvement. Things like task-base were
simply not realistically possible under the old system.
One of the big issues that was highlighted was should you RDEPEND on
fontconfig or libfontconfig? That would depend on whether you inherit
debian.bbclass or not. We don't require people to use debian.bbclass but
most just happen to. There are also other classes that do subtle
renaming (such as the kernel modules).
Solution: We now always use unrenamed package names in the runtime
variables and debian.bbclass handles renaming just as the packages are
created.
The problem is this isn't 100% foolproof. Consider:
RDEPENDS_A = "B"
RDEPENDS_B = "A"
Which do we build first? We can't package A without packaging B first
and vice versa.
In bitbake 1.3 there were certain types of circular dependencies we
errored on and shouldn't have done. In fixing those, I managed to let
errors like the above slip through the net. This problem still exists in
bitbake 1.6 as things like:
DEPENDS_A = "B"
RDEPENDS_B = "A"
doesn't error and should (assuming you use debian.bbclass). Thankfully,
these kind of dependencies very rarely happen.
As the RDEPENDS handling was added, the code in bitbake went out of
control and became unmaintainable. Arguably I understand it better than
anyone and I couldn't fix the above problem in the existing codebase.
Another related issue is that in bitbake 1.6, bitbake only handles
things as packages with no real understanding of the tasks that make up
the package which is really a dependency problem. I had problems trying
to express the task dependencies required by debian.bbclass. I also had
to make a choice about whether a multithreaded bitbake would operate at
the package or the task level. I chose the task level as it offers more
interesting possibilities in the future and addresses a lot more issues.
This did mean the core of bitbake would need rewriting as it was
previously package based.
At the time, nothing in the metadata properly explained the dependencies
at a task level. See these mails:
http://www.handhelds.org/hypermail/oe/102/10285.html
http://www.handhelds.org/hypermail/oe/102/10299.html
As you can see, I threw out the old dependency notation (bbdepcmd) and
replaced it with the items detailed above.
I also carefully considered what our expectations of things like "-c
fetch" are. For a long time, I've been getting confused as users want
"-c fetch" to fetch all dependencies for something like opie-image, yet
nothing in the metadata gives that dependency.
After much thought, I concluded that "-c fetch" should only run the
fetch task for the packages specified. To make "-c fetch" fetch all its
dependencies, you could add something like this to the metadata for
bitbake trunk:
do_fetch[recrdeptask] = "do_fetch"
I plan to either add an option "-c fetch -xyz" which simply injects the
above metadata fragment, or we add a fetchall task in OE which does this
and hence give users what they want/need in a maintainable way.
Note, we also lose the horrible BUILD_ALL_DEPS variable I added as a
mistake when working on bitbake 1.3 - whilst I hate the thing now, it
did buy us time to step back and fix all this properly though!
The final problem is that bitbake prior to 1.7 computes provider
decisions "on the fly". When it starts building, it has no idea what it
will end up doing. If/when a package fails, it would rethink what it was
doing and only then try and compute a way out. It would only find the
next alternative. This is the final barrier to multithreading - no
predetermined paths but all computed dynamically. Again, this cries out
for consideration as part of the rewrite. I'm acutally sad to lose the
dynamic approach but it has too many drawbacks (see usability below).
What did we do?
===============
Hopefully the above tells you why we needed to throw away some of the
old code. My plan was simple - implement a multithreading capable
bitbake and at the same time, rewrite the dependency code with sanity in
mind. I threw away the old code and added a new two level system:
taskdata.py - handles the metadata, works out the dependencies and
parses into a list of tasks
runqueue.py - takes the list of tasks, filters them, decides on the
optimal execution order and then runs them.
Some of the handling is quite subtle. taskdata's data structures are
reusable, runqueue's are not. When a package fails, we throw away the
runqueue and ask taskdata for a new list of tasks (if possible). It is
now hopefully structured code we can maintain with a semblance of an API
(not stable yet though!).
I'll also note that bitbake is actually *much* faster now. Compare the
speed of a bitbake opie-image --dry-run under bitbake 1.6 with the new
one. This is despite doing all the computation in advance! :)
Where are we now?
=================
The position in trunk is that these two modules basically work. They are
not hooked into the rest of bitbake in a way which exposes all their
power. New commandline options might help with the and/or improvements
to the metadata as mentioned above. Of course there are also the
inevitable corner cases in the metadata the new code highlights.
One is the circular dependency example mentioned above which affects
opie-mediaplayer1. I'm certain its not a bitbake issue but
debian.bbclass being flawed. The solution is to split packaging into two
stages:
1. packaging-prepare - split the files into the packages and calculate
the renaming
2. packaging - actually make the packages and write in the RDEPENDS
lines.
This means we can write:
do_package[rdeptask] = "do_package_prepare"
(instead of do_package[rdeptask] = "do_package")
and the whole circular dependency problem goes away.
I've already covered the "-c fetch" problem and the two potential
solutions.
Another current issue is handling of the "-f" option. taskdata and
runqueue need to be taught about that and currently it sometimes works
but is unpredictable.
The final issue I'm aware of is a usability one. I'm convinced
taskdata/runqueue work but their output to the user is even less helpful
than bitbake was previously (which was bad enough). I have see bitbake
stop dead seemingly with no output at the moment which is no good. I
have split things into logging domains as a first step to rectify this
but it still needs a ton of work. The problem is knowing when a given
message is important and the user needs to see it/do something about it
and when a message should just appear as low level debug. I'm fixing
cases of bad messages when I find them but I'm really going to need help
with this in both identifying the cases and improving the existing
messages.
The point to keep in mind is that it was near impossible to improve the
logging in the old dependency code due to its on the fly computation
nature. Under the new code, we actually have the dependency data in
advance and I'm therefore convinced that we stand a much better chance
of improving usability against this new backdrop.
I suspect I've rambled enough now :)
If anyone wants to discuss any of this or better still help with the
code, please do so!
Richard
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Bitbake past, present and future [long]
2006-09-26 14:28 Bitbake past, present and future [long] Richard Purdie
@ 2006-10-02 13:00 ` Paul Sokolovsky
2006-10-02 13:55 ` Richard Purdie
0 siblings, 1 reply; 3+ messages in thread
From: Paul Sokolovsky @ 2006-10-02 13:00 UTC (permalink / raw)
To: Richard Purdie
Cc: Using the OpenEmbedded metadata to build Linux Distributions,
bitbake-dev
Hello Richard,
Tuesday, September 26, 2006, 5:28:15 PM, you wrote:
> Paul's comments in #oe have highlighted the fact that whilst I and
> perhaps some others know where things are going (and have come from), a
> lot of things are in my head which isn't perhaps the best place for
> them.
Richard, thanks for this comprehensive discussion. Before rushing
with (stupid) questions, I decided to (re)read bitbake-dev and other
archives to have clearer picture myself. I've captured what I found at
http://www.openembedded.org/bitbakebackground (linked from OE's wiki
frontpage).
With this overall picture in mind, the changes in bitbake over last
year (most of which were led by you) are indeed big and highly
improving, and it's IMHO clear that they should be continued, until
BitBake and OE metatada would indeed scale well in both perfomance and
maintenance.
I still don't have general understanding of BitBake internal
functioning, but I guess, the best thing I can do is find answer to my
specific questions myself in the code.
But I have to questions of general nature:
1. What is status of bitbake-ng?
IIRC, once info about it was in OE wiki. But now searching for it
returns only that it is scheduled topic for OEDEM. So, I guess,
exact answers will be known after it, and so far it's in "postponed"
state. Well, I cannot say that I personally regret aboy this - it's
possible to implement non-so-scalable patterns (or antipatterns) in C
as well, but C brings segfaults and higher steep hacking curve with
it. Python seems like very perfect language for the tool like BitBake.
2. Using structured secondary storage (i.e. SQL db) as datastore
No surprise, I wasn't the first to consider sqlite for the backend ;-)
- Holger tried that long ago,
https://lists.berlios.de/pipermail/bitbake-dev/2005-May/000018.html
So, my question would be: after all the refactors BitBake undergone
since that, would sqlite backend be more feasible?
But again, I understand, the answer will likely be: "try and see".
So, I'm going to understand internal datastructures of BitBake
better first. And in the meantime, work on some trivial/small (thanks
to Python!) tweaks/improvements. One thing I want to grasp first is
unittesting of BitBake. Again, I'm glad there's bitbake-tests
directory in BB trunk already.
[]
> If anyone wants to discuss any of this or better still help with the
> code, please do so!
> Richard
--
Best regards,
Paul mailto:pmiscml@gmail.com
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: Bitbake past, present and future [long]
2006-10-02 13:00 ` Paul Sokolovsky
@ 2006-10-02 13:55 ` Richard Purdie
0 siblings, 0 replies; 3+ messages in thread
From: Richard Purdie @ 2006-10-02 13:55 UTC (permalink / raw)
To: Paul Sokolovsky
Cc: Using the OpenEmbedded metadata to build Linux Distributions,
bitbake-dev
Hi Paul,
On Mon, 2006-10-02 at 16:00 +0300, Paul Sokolovsky wrote:
> Richard, thanks for this comprehensive discussion. Before rushing
> with (stupid) questions, I decided to (re)read bitbake-dev and other
> archives to have clearer picture myself. I've captured what I found at
> http://www.openembedded.org/bitbakebackground (linked from OE's wiki
> frontpage).
That's helpful, thanks. We do need to work on the documentation but a
set of links like that will be useful for others.
Its also interesting to see how things have changed!
> With this overall picture in mind, the changes in bitbake over last
> year (most of which were led by you) are indeed big and highly
> improving, and it's IMHO clear that they should be continued, until
> BitBake and OE metatada would indeed scale well in both perfomance and
> maintenance.
That is the aim :)
> I still don't have general understanding of BitBake internal
> functioning, but I guess, the best thing I can do is find answer to my
> specific questions myself in the code.
If you have some specific questions, do feel free to ask them. Someone
should be able to at least point you at the code in question. I've been
working to try and modularise the bitbake code base so you shouldn't hit
quite as steep a learning curve as there once was.
> But I have to questions of general nature:
>
> 1. What is status of bitbake-ng?
>
> IIRC, once info about it was in OE wiki. But now searching for it
> returns only that it is scheduled topic for OEDEM. So, I guess,
> exact answers will be known after it, and so far it's in "postponed"
> state. Well, I cannot say that I personally regret aboy this - it's
> possible to implement non-so-scalable patterns (or antipatterns) in C
> as well, but C brings segfaults and higher steep hacking curve with
> it. Python seems like very perfect language for the tool like BitBake.
What I said a year ago basically still stands as far as I'm concerned.
Back then I didn't understand the bitbake internals and said I'd need to
learn them first. Having learnt a lot about them, modified them and
tried to tune them for performance, I still think we're better off
moving the current code base forwards rather than starting again on a C
based -ng version. I think python does lend itself to what we're doing.
Having said that, I can see certain bits of bitbake being rewritten in
C, particularly the parser and the data modules.
We also totally lack a set of developers to write bitbake-ng anyway,
even if I did think it was a good idea.
> 2. Using structured secondary storage (i.e. SQL db) as datastore
>
> No surprise, I wasn't the first to consider sqlite for the backend ;-)
> - Holger tried that long ago,
> https://lists.berlios.de/pipermail/bitbake-dev/2005-May/000018.html
>
> So, my question would be: after all the refactors BitBake undergone
> since that, would sqlite backend be more feasible?
>
> But again, I understand, the answer will likely be: "try and see".
In short, no, and I don't think sqlite is ever going to work without a
different kind of major re-factoring.
I was once of the "sqlite will solve all our problems" opinion but you
need to understand the way bitbake uses its data. The data module gets
*hammered*. I mean really **hammered**. It sees hundreds of thousands of
variable lookups and expansions. Put SQL in there and you slow down
bitbake by orders of magnitude as python dictionaries are faster.
Even if we can change the parser and the way bitbake uses variables to
avoid this hammering, it doesn't change the fact that a python
dictionary will be faster. The only other consideration is memory usage
but we basically have that under control now. As we constrain our usage
of python dictionaries in the data class, it may be possible a specially
designed python class might be faster, or that a C based solution could
be faster but these are things someone needs to experiment with. I
briefly tried both and didn't have much success.
Also, recently, I tried using sqlite for taskdata/runqueue. When I
ripped it out and used python dictonaries, I got a 5 times speed
increase. Every time I've tried to use sqlite, I've been
disappointed :-(.
I can give some results of some profiling I did recently. bitbake spends
a lot of time in the expand function in data.py. All variables are
expanded when looked up and this is a time consuming activity. zecke has
worked wonders on that with certain caches to speed up lookups but it
still remains our biggest bottleneck.
485160/276302 11.060 0.000 79.150 0.000 lib/bb/data_smart.py:53(expand)
96791/46888 10.390 0.000 54.620 0.001 :0(eval)
470029 7.120 0.000 18.160 0.000 lib/bb/data_smart.py:170(getVarFlag)
295446/37522 7.040 0.000 72.230 0.002 :0(sub)
409472/70517 6.080 0.000 68.260 0.001 lib/bb/data_smart.py:155(getVar)
287386/155778 5.720 0.000 55.710 0.000 lib/bb/data_smart.py:54(var_sub)
324100 5.300 0.000 8.340 0.000 /usr/lib/python2.4/copy.py:75(copy)
627840 4.210 0.000 4.210 0.000 :0(find)
217970 3.590 0.000 5.680 0.000 /usr/lib/python2.4/posixpath.py:56(join)
502765 3.270 0.000 3.270 0.000 lib/bb/data_smart.py:95(_findVar)
96791/46888 3.230 0.000 56.750 0.001 lib/bb/data_smart.py:65(python_sub)
513155 2.620 0.000 2.620 0.000 :0(group)
3221 2.170 0.001 33.110 0.010 <bb>:1(base_set_filespath)
357710 1.900 0.000 1.900 0.000 :0(get)
96791/46888 1.810 0.000 49.160 0.001 <string>:0(?)
60034 1.760 0.000 3.410 0.000 lib/bb/COW.py:82(__getitem__)
36388/10786 1.350 0.000 6.880 0.001 lib/bb/parse/parse_py/BBHandler.py:199(feeder)
66398 1.330 0.000 1.330 0.000 :0(stat)
65874 1.330 0.000 2.640 0.000 /usr/lib/python2.4/posixpath.py:168(exists)
2102 1.230 0.001 5.520 0.003 lib/bb/__init__.py:349(which)
218019 1.150 0.000 1.150 0.000 :0(endswith)
85356 1.070 0.000 1.070 0.000 :0(match)
188910 1.040 0.000 1.040 0.000 :0(append)
120707/64380 1.080 0.000 52.940 0.001 lib/bb/data.py:89(getVar)
Its obvious that the data implementation or more productively, the usage
of the data implementation can be improved. Other interesting areas are:
usr/lib/python2.4/posixpath.py:56(join) - can we avoid some of these?
<bb>:1(base_set_filespath) - this is a horrible function and I'm sure we
could do better, maybe with a total rewrite and/or rethink
/usr/lib/python2.4/posixpath.py:168(exists) - add an internal function +
cache for this (combine with a centralised mtime cache?).
Now, if only I could get call graphing working properly... :)
> So, I'm going to understand internal datastructures of BitBake
> better first. And in the meantime, work on some trivial/small (thanks
> to Python!) tweaks/improvements. One thing I want to grasp first is
> unittesting of BitBake. Again, I'm glad there's bitbake-tests
> directory in BB trunk already.
Sounds good. zecke is the QA expert and the one to ask about the tests.
Cheers,
Richard
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-10-02 14:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-26 14:28 Bitbake past, present and future [long] Richard Purdie
2006-10-02 13:00 ` Paul Sokolovsky
2006-10-02 13:55 ` Richard Purdie
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.