Optimize YumPackageInstaller: Use 'rpm -q' instead of 'yum list installed#2753
Merged
Periecle merged 1 commit intoPlaytikaOSS:developfrom Feb 6, 2026
Conversation
…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>
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
amizurov
reviewed
Feb 6, 2026
...ainers-common/src/main/java/com/playtika/testcontainer/common/utils/YumPackageInstaller.java
Show resolved
Hide resolved
amizurov
previously approved these changes
Feb 6, 2026
Contributor
|
@Periecle Thanks a lot. |
67d62ef to
a56539a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Optimize YumPackageInstaller: Use 'rpm -q' instead of 'yum list installed'
This change optimizes the package existence check in
YumPackageInstallerby replacing the expensiveyum list installedcommand with the much fasterrpm -q <package>.yum list installediterates over all installed packages, which is an O(N) operation and incurs significant overhead.rpm -qperforms a direct lookup in the RPM database (O(1) / O(log N)).Changes:
executeCommandtoPackageInstallerto allow executing commands without enforcing exit code 0 (needed forrpm -qon missing packages).YumPackageInstaller.shouldInstallto userpm -q.YumPackageInstallerTestto verify the logic.Performance Impact:
yum list installed.