Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use dlocate list instead of dpkg query #1923

Merged
merged 1 commit into from
Mar 26, 2024

Conversation

afbjorklund
Copy link
Contributor

@afbjorklund afbjorklund commented Mar 20, 2024

Previously dlocate was only used for half of the process, not both.

It is better to use dlocate for both lookups, and avoid dpkg here.

Also makes results consistent, as the dlocatedb is updated daily.


This speeds up the execution time by 10x, when dlocate is installed.

It makes podman info takes 5-10 seconds, because it queries so many...

@afbjorklund

This comment was marked as resolved.

@rhatdan
Copy link
Member

rhatdan commented Mar 21, 2024

/approve
LGTM

pkg/version/version.go Outdated Show resolved Hide resolved
@afbjorklund
Copy link
Contributor Author

afbjorklund commented Mar 21, 2024

Converting the text files to a database would gain another 10x speedup, at the cost of generating the dbm (~10 seconds)

Currently the main issue is the disk size (100M), which can be brought down to 10M with adding some new compression

None of this would be needed for (or implemented in) podman...

But it would bring down the deb times, to be more similar to rpm?


For fun, I made just such a program: https://github.com/afbjorklund/debfile

It brings the query time down from 1 second, to 5 milliseconds (200x speedup)

Maybe if it gets popular, it could be used as well. But dlocate seems orphaned?

https://tracker.debian.org/pkg/dlocate (last modified in 1.08 : Sun, 26 Dec 2021)

Previously dlocate was only used for half of the process, not both.

Use the dlocatedb for both lookups, both package list and file list.

Signed-off-by: Anders F Björklund <anders.f.bjorklund@gmail.com>
@afbjorklund
Copy link
Contributor Author

Once the move from podman to common is complete, it could do with some refactoring.

The special cases for dpkg/dlocate, and for pacman/apk, could be moved into functions?

@afbjorklund
Copy link
Contributor Author

afbjorklund commented Mar 24, 2024

If there were any unit tests, they would look for cases similar to these two:

$ dpkg-query -W podman
podman	100:3.4.2-5
$ dpkg-query -W -f '${Package}_${Version}:${Architecture}\n' podman
podman_100:3.4.2-5:amd64
$ dlocate -l '^..\spodman\s'
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Installed/Config-files/Unpacked/Failed-config/Half-installed
|/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad)
||/ Name           Version        Description
+++-==============-==============-==============================================
ii  podman         100:3.4.2-5:am Manage pods, containers and container images.
$ COLUMNS=160 dlocate -l '^..\spodman\s'
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Installed/Config-files/Unpacked/Failed-config/Half-installed
|/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad)
||/ Name                               Version                            Description
+++-==================================-==================================-======================================================================================
ii  podman                             100:3.4.2-5:amd64                  Manage pods, containers and container images.

@rhatdan
Copy link
Member

rhatdan commented Mar 25, 2024

@giuseppe PTAL

Copy link
Member

@giuseppe giuseppe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

openshift-ci bot commented Mar 26, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: afbjorklund, giuseppe, rhatdan

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@rhatdan
Copy link
Member

rhatdan commented Mar 26, 2024

/lgtm

@openshift-ci openshift-ci bot added the lgtm label Mar 26, 2024
@openshift-merge-bot openshift-merge-bot bot merged commit f41f8be into containers:main Mar 26, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants