[opkg][opkg 0.4.2] "opkg configure" in run-postinsts taking 8s.

43 views
Skip to first unread message

abdul karim

unread,
Feb 10, 2021, 10:20:32 AM2/10/21
to opkg-devel
Hi all,
Our yocto based Linux BSP for NXP board i.MX6ULLEVK uses opkg as a package manager.
run-postinsts.service runs the command "opkg configure" which seems to take around 8s.
I further looked into the opkg source and found that this loop is consuming 8s of time.
https://git.yoctoproject.org/cgit/cgit.cgi/opkg/tree/libopkg/opkg_cmd.c?h=v0.4.2#n358 and is run 938 times.
why do you think is it taking this much time and how can we reduce this?

Thanking you in anticipation.
Abdul karim

Alex Stewart

unread,
Feb 11, 2021, 1:27:00 PM2/11/21
to opkg-...@googlegroups.com, abdul karim
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

Reply all
Reply to author
Forward
0 new messages