Bug 8432 - too slow update-mime-database
: too slow update-mime-database
Status: CONFIRMED
Product: Desktop Bugs
Classification: ROSA Desktop
Component: Main Packages
: Fresh
: All Linux
: Normal normal
: ---
Assigned To: ROSA Linux Bugs
: ROSA Linux Bugs
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2017-10-26 17:52 MSD by Sergei Trusov
Modified: 2017-10-26 18:11 MSD (History)
0 users

See Also:
RPM Package: shared-mime-info
ISO-related:
Bad POT generating:
Upstream:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sergei Trusov 2017-10-26 17:52:39 MSD
Description of problem:

Running

/usr/bin/update-mime-database /usr/share/mime 

takes inappropriate long time

This may affect system update process. CPU usage is low but all disk operations are slow, delaying UI response. The observable behaviour is confusing.

Similar bugs in other distros
https://bugzilla.redhat.com/show_bug.cgi?id=1052173
https://bugs.gentoo.org/487504

Version-Release number of selected component (if applicable):

ROSA R9 (and all previous)


How reproducible:

Allways


Steps to Reproduce:

1. 

$ time sudo /usr/bin/update-mime-database /usr/share/mime 

real    0m30,043s
user    0m0,580s
sys     0m0,611s


2.

$ time sudo PKGSYSTEM_ENABLE_FSYNC=0 /usr/bin/update-mime-database /usr/share/mime 

real    0m0,644s
user    0m0,486s
sys     0m0,151s

The last case shows how this issue can be fixed.
Comment 1 Sergei Trusov 2017-10-26 17:58:50 MSD
Gentoo just builds update-mime-database with fdatasync() call disabled.


openSUSE 42.3 uses the following /etc/rpm/macros.shared-mime-info

# RPM macros for packages installing a MIME type according to the XDG specification
#
###
#
# When a package installs a MIME type as per the XDG specification, it should
# use both macros:
#
#  - %mime_database_post in %post
#  - %mime_database_postun in %postun
#
# Note that these macros can optionally take as argument the directory
# where the MIME type is installed. If no argument is passed, then
# %{_datadir}/mime will be used (which is where applications usually install
# the MIME type information).
#
###

# On install, update the mime database
%mime_database_post()                                          \
export PKGSYSTEM_ENABLE_FSYNC=0                                \
if test -x %{_bindir}/update-mime-database; then               \
%if "x%1" != "x%%1"                                            \
  %{_bindir}/update-mime-database "%1" || true                 \
%else                                                          \
  %{_bindir}/update-mime-database "%{_datadir}/mime" || true   \
%endif                                                         \
fi 

# On uninstall, update the mime database. Note: we ignore upgrades (already
# handled in %post of the new package).
%mime_database_postun()                                        \
export PKGSYSTEM_ENABLE_FSYNC=0                                \
if [ $1 -eq 0 ]; then                                          \
  if test -x %{_bindir}/update-mime-database; then             \
%if "x%1" != "x%%1"                                            \
    %{_bindir}/update-mime-database "%1" || true               \
%else                                                          \
    %{_bindir}/update-mime-database "%{_datadir}/mime" || true \
%endif                                                         \
  fi                                                           \
fi
Comment 2 Sergei Trusov 2017-10-26 18:11:06 MSD
The easiest way seems to provide /etc/profile.d/update-mime-database.sh with

export PKGSYSTEM_ENABLE_FSYNC=0

However, according to Bastien Nocera, this should be done by package manager.

So the above solution is in question.