Packages (Linux): Improve emerge detection speed#2406
Open
keremgokcek wants to merge 2 commits into
Open
Conversation
Up to standards ✅🟢 Issues
|
Contributor
There was a problem hiding this comment.
Pull request overview
Improves Gentoo (emerge/Portage) package counting performance on Linux by avoiding recursive per-package file existence checks under /var/db/pkg and instead aggregating directory counts per category.
Changes:
- Added
getEmergePackagesImpl()/getEmergePackages()to count installed emerge packages by summing directory counts within each Portage category. - Switched EMERGE counting in
getPackageCounts()fromcountFilesRecursive(..., "SIZE")to the new directory-count approach.
Comment on lines
+469
to
+473
| struct dirent *entry; | ||
| while ((entry = readdir(dirp)) != NULL) | ||
| { | ||
| if (entry->d_type != DT_DIR || entry->d_name[0] == '.') | ||
| continue; |
Comment on lines
+461
to
+462
| static uint32_t getEmergePackagesImpl(FFstrbuf* baseDir) | ||
| { |
Comment on lines
+480
to
+481
| static uint32_t getEmergePackages(FFstrbuf* baseDir, const char* dirname) | ||
| { |
Member
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.
Summary
Makes emerge package count detection faster.
Changes
Instead of listing every package's directory in every category to check if
SIZEfile exist, now it just counts the number of directories in every category folder. This decreases the number of directory listing operations by the number of packages. It's especially noticeable on cold boots.Documentation of directory: https://wiki.gentoo.org/wiki//var/db/pkg
i7-5500U + SSD with 889 emerge and 11 flatpak user packages installed:
On cold boot: 350 ms -> 30 ms
On regular usage: 3 ms -> 0.9 ms
C2D T7200 + HDD with 438 emerge packages installed:
On cold boot: 2480 ms -> 1000 ms
On regular usage: 1.9 ms -> 0.8 ms
Checklist