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 2120692

Summary: speedup magic matching
Product: Red Hat Enterprise Linux 9 Reporter: Vincent Mihalkovič <vmihalko>
Component: fileAssignee: Vincent Mihalkovič <vmihalko>
Status: CLOSED ERRATA QA Contact: Karel Volný <kvolny>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 9.0CC: fsumsal, kdudka, kvolny, lzaoral, sgrubb
Target Milestone: rcKeywords: Triaged
Target Release: ---Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: file-5.39-10.el9 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-11-15 11:23:27 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 Vincent Mihalkovič 2022-08-23 14:38:52 UTC
From https://mailman.astron.com/pipermail/file/2022-March/000685.html:

rpm(1) and rpmlint(1) and probably other applications are using
libmagic to mass-determine the filetype
of files to process into a package. While looking at that, I noticed
that libmagic is quite slow when
it is processing large text-like files. This is because of many
complicated regexps being processed,
and the regexes are compiled repeatedly. regexp compilation is very
time consuming compared to regexp matching,
so it helps to do that only once and cache the result for further processing.

On a 64bit host this adds about 200kb of RAM usage, but it improves
matching speed by factor 2 - 4, which
is very noticeable when processing a larger directory of files.

follow-ups:
(0) https://mailman.astron.com/pipermail/file/2022-March/000685.html
(0) https://github.com/file/file/commit/4c8a4d8dbab1e73bfb30e391dcec49fcf269f84
    (0.1)  https://mailman.astron.com/pipermail/file/2022-March/000705.html
    (0.1) https://github.com/file/file/commit/7d438e28c16773e28a3707935c8e5d9927a515a7
    (0.2) https://mailman.astron.com/pipermail/file/2022-April/000718.html
    (0.2) https://github.com/file/file/commit/d1a00ae92b2cf09298615cf3aba474d8fec7380f
    (0.3) https://mailman.astron.com/pipermail/file/2022-April/000720.html
    (0.3) https://github.com/file/file/commit/4254a0afecfd2ae200c694dfcf93f4b4ac21652e

(1) https://mailman.astron.com/pipermail/file/2022-March/000688.html
(1) https://github.com/file/file/commit/a4b3abc4104d8a4eeb84a6242f2f1a830204a539
(2) https://mailman.astron.com/pipermail/file/2022-March/000693.html
(2) https://github.com/file/file/commit/d17d8e9ff8ad8e95fdf66239ccdcc2133d1ce5ce
(3) https://mailman.astron.com/pipermail/file/2022-March/000684.html
(3) https://github.com/file/file/commit/14b5d7aa0b55275969809fdf84e8a8caee857c0f

Version-Release number of selected component (if applicable):
file-5.39-8.el9

All this changes are already in fedora-37 from file-5.42-4.fc37

This Bugzilla was created to ensure backporting of these commits into RHEL-9.1.

Comment 9 errata-xmlrpc 2022-11-15 11:23:27 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 (file bug fix and enhancement update), 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/RHBA-2022:8406