Skip to content

Optimize YumPackageInstaller: Use 'rpm -q' instead of 'yum list installed#2753

Merged
Periecle merged 1 commit intoPlaytikaOSS:developfrom
Periecle:yum-package-installer-optimization-14966541051697227319
Feb 6, 2026
Merged

Optimize YumPackageInstaller: Use 'rpm -q' instead of 'yum list installed#2753
Periecle merged 1 commit intoPlaytikaOSS:developfrom
Periecle:yum-package-installer-optimization-14966541051697227319

Conversation

@Periecle
Copy link
Collaborator

@Periecle Periecle commented Jan 30, 2026

Optimize YumPackageInstaller: Use 'rpm -q' instead of 'yum list installed'

This change optimizes the package existence check in YumPackageInstaller by replacing the expensive yum list installed command with the much faster rpm -q <package>.

yum list installed iterates over all installed packages, which is an O(N) operation and incurs significant overhead. rpm -q performs a direct lookup in the RPM database (O(1) / O(log N)).

Changes:

  • Added executeCommand to PackageInstaller to allow executing commands without enforcing exit code 0 (needed for rpm -q on missing packages).
  • Updated YumPackageInstaller.shouldInstall to use rpm -q.
  • Added YumPackageInstallerTest to verify the logic.

Performance Impact:

  • Theoretical complexity reduction from O(N) to O(1).
  • Avoids parsing large output from yum list installed.
  • Improves correctness by avoiding partial string matching issues (e.g. finding "foo-bar" when checking for "foo").

…lled'

This change optimizes the package existence check in `YumPackageInstaller`
by replacing the expensive `yum list installed` command with the much
faster `rpm -q <package>`.

`yum list installed` iterates over all installed packages, which is an
O(N) operation and incurs significant overhead. `rpm -q` performs a
direct lookup in the RPM database (O(1) / O(log N)).

Changes:
- Added `executeCommand` to `PackageInstaller` to allow executing commands
  without enforcing exit code 0 (needed for `rpm -q` on missing packages).
- Updated `YumPackageInstaller.shouldInstall` to use `rpm -q`.
- Added `YumPackageInstallerTest` to verify the logic.

Performance Impact:
- Theoretical complexity reduction from O(N) to O(1).
- Avoids parsing large output from `yum list installed`.
- Improves correctness by avoiding partial string matching issues (e.g.
  finding "foo-bar" when checking for "foo").

Co-authored-by: Periecle <26135126+Periecle@users.noreply.github.com>
@Periecle Periecle changed the title Optimize YumPackageInstaller: Use 'rpm -q' instead of 'yum list insta… Optimize YumPackageInstaller: Use 'rpm -q' instead of 'yum list installed Jan 30, 2026
@codecov
Copy link

codecov bot commented Jan 30, 2026

Codecov Report

❌ Patch coverage is 66.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 81.82%. Comparing base (930047f) to head (a56539a).
⚠️ Report is 2 commits behind head on develop.

Files with missing lines Patch % Lines
...a/testcontainer/common/utils/PackageInstaller.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             develop    #2753      +/-   ##
=============================================
+ Coverage      81.68%   81.82%   +0.14%     
- Complexity       848      852       +4     
=============================================
  Files            202      202              
  Lines           2986     2987       +1     
  Branches         150      150              
=============================================
+ Hits            2439     2444       +5     
+ Misses           474      470       -4     
  Partials          73       73              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@amizurov amizurov self-assigned this Feb 6, 2026
amizurov
amizurov previously approved these changes Feb 6, 2026
@amizurov
Copy link
Contributor

amizurov commented Feb 6, 2026

@Periecle Thanks a lot.

@amizurov amizurov assigned Periecle and unassigned amizurov and Periecle Feb 6, 2026
@Periecle Periecle force-pushed the yum-package-installer-optimization-14966541051697227319 branch from 67d62ef to a56539a Compare February 6, 2026 15:16
@Periecle Periecle merged commit 3e4fd8b into PlaytikaOSS:develop Feb 6, 2026
8 of 10 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.

2 participants