Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1704354

Summary: Parallelize /usr/lib/rpm/check-buildroot
Product: Red Hat Enterprise Linux 8 Reporter: Denys Vlasenko <dvlasenk>
Component: rpmAssignee: Florian Festi <ffesti>
Status: CLOSED ERRATA QA Contact: Jan Blazek <jblazek>
Severity: medium Docs Contact:
Priority: medium    
Version: 8.0CC: ksrot, pmatilai, pmoravco, qe-baseos-security
Target Milestone: rcKeywords: FutureFeature, Triaged
Target Release: 8.0Flags: pm-rhel: mirror+
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: rpm-4.14.2-33.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-04-28 16:51:12 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Denys Vlasenko 2019-04-29 15:44:31 UTC
Please backport fix for Fedora bz 1704353.

Copying its description below:

Kernel's rpm build process executes this command at a certain stage:

/usr/lib/rpm/check-buildroot

which is a shell script. At this point, kernel build tree has ~60 thousand files. The script greps almost all of these files:

find "$RPM_BUILD_ROOT" \! \( \
    -name '*.pyo' -o -name '*.pyc' -o -name '*.elc' -o -name '.packlist' \
    \) -type f -print0 | \
    LANG=C xargs -0r grep -F "$RPM_BUILD_ROOT" >$tmp

This runs grep on only one CPU, which is rather suboptimal. Our build machines usually have >10 CPUs.

Proposed improvement is to use xargs -P<num_cpus>, a-la:

find "$RPM_BUILD_ROOT" \! \( \
    -name '*.pyo' -o -name '*.pyc' -o -name '*.elc' -o -name '.packlist' \
    \) -type f -print0 | \
    LANG=C xargs -0r -P`nproc` grep -F "$RPM_BUILD_ROOT" >$tmp


Testing on a 8-thread Skylake CPU:

Ran both scripts on my /usr tree (17 gbytes, does not fit into RAM cache):
                Before:
17:23:50 UD.............. io:934m    0 forks:  11
17:23:55 UD.............. io:911m 300k forks:  18
17:24:00 S............... io:368m    0 forks:  45
17:24:05 S............... io:483m    0 forks:  32
17:24:10 U............... io:380m 184k forks:  37
17:24:15 UD.............. io:506m  64k forks:  69
17:24:20 SU.............. io:442m    0 forks:  78
17:24:25 UD.............. io:1.0g    0 forks:   3
17:24:30 UD.............. io:1.1g    0 forks:   3
17:24:35 UD.............. io:978m    0 forks:  23
17:24:40 UD.............. io:1.2g  36k forks:   2
17:24:45 UD.............. io:1.2g  72k forks:   4
17:24:50 UD.............. io:1.1g    0 forks:  11
17:24:55 UD.............. io:1.1g    0 forks:   6
17:25:00 UD.............. io:952m    0 forks:  14
17:25:05 ................ io:281m    0 forks:   2
real    1m15.273s
user    0m35.866s
sys     0m9.906s
                After:
17:25:25 SUUDDD.......... io:1.6g    0 forks:  29
17:25:30 SSUUDDD......... io:1.7g    0 forks: 177
17:25:35 SUUDDDD......... io:2.1g    0 forks:  85
17:25:40 SUUUDDDD........ io:2.0g    0 forks:  26
17:25:45 SUUUDDDD........ io:2.1g 4096 forks:  17
17:25:50 SUUDDD.......... io:1.9g  56k forks:  13
real    0m28.508s                                                                           
user    0m36.859s                                                                           
sys     0m10.688s

And on /usr/lib (9.2 gbytes, completely cached in RAM before the test):
                Before:                      
17:28:31 U............... io:   0    0 forks:   4
17:28:32 UU.............. io:   0    0 forks:   1
17:28:33 UU.............. io:   0  16k forks:   0
17:28:34 UU.............. io:   0    0 forks:   2
17:28:35 UU.............. io: 56k  80k forks:   7
17:28:36 UU.............. io:   0 132k forks:   1                           
17:28:37 UU.............. io:   0    0 forks:  19                           
17:28:38 UU.............. io:   0    0 forks:   2                           
17:28:39 UU.............. io:   0    0 forks:   1                           
17:28:40 UU.............. io:   0    0 forks:   2                           
17:28:41 UU.............. io:   0    0 forks:   1                                           
17:28:42 UU.............. io:   0    0 forks:  10
17:28:43 UU.............. io:   0    0 forks:   1
17:28:44 UU.............. io:   0    0 forks:   1
17:28:45 UU.............. io:   0    0 forks:   2
17:28:46 UU.............. io:   0    0 forks:   1
17:28:47 UU.............. io:   0    0 forks:   1
17:28:48 UU.............. io:   0    0 forks:  14
real    0m17.147s
user    0m15.670s
sys     0m1.555s
                After:
17:28:54 SUUUUUUUUUUUUUU. io:   0    0 forks:  33
17:28:55 SUUUUUUUUUUUUUUU io:   0    0 forks:  17
17:28:56 SUUUUUUUUUU..... io:   0    0 forks:  16
real    0m3.205s
user    0m19.408s
sys     0m1.869s

Comment 9 errata-xmlrpc 2020-04-28 16:51:12 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHEA-2020:1835