Hey Adbul,
> why do you think is it taking this much time
The way I read that functions algorithm is:
```
foreach package known to opkg:
descend into the pkg's dependencies recursively:
if we already added the dep to the output vector:
skip it
else:
add the dep to the output vector
...
foreach pkg in the output vector:
configure it
```
The intention being that the output vector (and therefore configuration)
is ordered with all leaf dependencies first.
So the outer-most loop runs 938 times because - I assume - you have ~938
packages in the opkg source indexes. I can't comment on the real-time
that it takes to execute the loop, since that's obviously dependent on
your machine.
> how can we reduce this?
Since you're asking opkg to configure *all* packages, I don't see a way
around visiting every package in the outermost loop.
But, you might get some performance benefit out of optimizing the search
through the *previously-visited* collection[1]. At the moment, it's just
doing a linear search; but you might be able to store that data more
efficiently in a hash map and reduce the access cost for large indexes.
[1]
https://git.yoctoproject.org/cgit/cgit.cgi/opkg/tree/libopkg/opkg_cmd.c#n276
Alternatively: I assume you're using libsolv as your backend solver
(since it's the default in OE). libsolv[2] might be able to order the
dependency vector for us. I haven't dug around enough in the libsolv API
to know exactly what to recommend, but you might investigate if building
a libsolv package pool object and having libsolv do some kind of
reverse-solve is faster than the solver-agnostic implementation in
`opkg_cmd.c`.
[2]
https://github.com/openSUSE/libsolv
Hope that helps,
--
Alex Stewart
Software Engineer - NI Real-Time OS
NI (National Instruments)
alex.s...@ni.com