FS#66687 - [shared-mime-info] fdatasync() is no longer disabled after the package switches to meson

Attached to Project: Arch Linux
Opened by Chih-Hsuan Yen (yan12125) - Sunday, 17 May 2020, 12:34 GMT
Last edited by Andreas Radke (AndyRTR) - Monday, 18 May 2020, 11:08 GMT
Task Type Bug Report
Category Packages: Extra
Status Closed
Assigned To Jan de Groot (JGC)
Andreas Radke (AndyRTR)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 1
Private No

Details

Description:

To speed up /usr/bin/update-mime-database, ac_cv_func_fdatasync=no was added to prevent fdatasync() from being used [1]. After switching to meson [2], that option has no affects, and thus running update-mime-database.hook takes much longer time [3].

[1] https://bugs.archlinux.org/task/38836
[2] https://git.archlinux.org/svntogit/packages.git/commit/trunk?h=packages/shared-mime-info&id=bfe4b10c671319c1739c4c7cd18270b06f28468b
[3] https://bbs.archlinux.org/viewtopic.php?id=255817

Additional info:
extra/shared-mime-info 2.0+1+g6bf9e4f-1

Steps to reproduce:
Installing/upgrading any package with MIME data. For example `pacman -S shared-mime-info`.
This task depends upon

Closed by  Andreas Radke (AndyRTR)
Monday, 18 May 2020, 11:08 GMT
Reason for closing:  Fixed
Comment by Andreas Radke (AndyRTR) - Sunday, 17 May 2020, 17:58 GMT Comment by Chih-Hsuan Yen (yan12125) - Monday, 18 May 2020, 03:46 GMT
Oh! It's beyond my expectation that meson does not allow override function checks like autotools.

Anyway, before the upstream issue is fixed, how about adding PKGSYSTEM_ENABLE_FSYNC=0 to update-mime-database.hook like I did in https://bbs.archlinux.org/viewtopic.php?pid=1905481#p1905481?
Comment by Andreas Radke (AndyRTR) - Monday, 18 May 2020, 05:29 GMT
from man update-mime-database

-n Only update if MIME-DIR/packages/ or a file in that directory is newer than MIME-DIR/version. This is useful for package
pre- and post-installation scripts.

Compare "time /usr/bin/update-mime-database -V /usr/share/mime" vs. "time /usr/bin/update-mime-database -Vn /usr/share/mime".

I guess it should be enough to add "-n" to the hook:

-Exec = /usr/bin/update-mime-database /usr/share/mime
+Exec = /usr/bin/update-mime-database -n /usr/share/mime

I found at least Fedora is doing it this way.
Comment by Chih-Hsuan Yen (yan12125) - Monday, 18 May 2020, 05:55 GMT
`-n` does not help from the perspective of update-mime-database.hook as that hook only runs when there are some changes in `usr/share/mime/packages/*.xml`. Here are some values from running `pacman -S libfm-qt`:

1. With `Exec = /usr/bin/time /usr/bin/update-mime-database /usr/share/mime` in the hook

0.29user 0.12system 0:38.05elapsed 1%CPU (0avgtext+0avgdata 66988maxresident)k
0inputs+8040outputs (0major+15459minor)pagefaults 0swaps

2. With `Exec = /usr/bin/time /usr/bin/update-mime-database -n /usr/share/mime` in the hook

0.27user 0.14system 0:39.58elapsed 1%CPU (0avgtext+0avgdata 66852maxresident)k
0inputs+8040outputs (0major+15456minor)pagefaults 0swaps

On the other hand, with `Exec = /usr/bin/time /usr/bin/env PKGSYSTEM_ENABLE_FSYNC=0 /usr/bin/update-mime-database /usr/share/mime`

0.23user 0.06system 0:00.30elapsed 99%CPU (0avgtext+0avgdata 66856maxresident)k
0inputs+8040outputs (0major+15519minor)pagefaults 0swaps

Environment: Western Digital hard disk WD10EZEX-08WN4A0 (7200rpm) + ext4 for rootfs
Comment by Andreas Radke (AndyRTR) - Monday, 18 May 2020, 07:08 GMT
Does it give any further improvement to additionally add "-n"
Exec = /usr/bin/time /usr/bin/env PKGSYSTEM_ENABLE_FSYNC=0 /usr/bin/update-mime-database -n /usr/share/mime` ?
Comment by Chih-Hsuan Yen (yan12125) - Monday, 18 May 2020, 07:34 GMT
Hmm, the time is slightly longer with `-n` (0.30 sec -> 0.51 sec). I guess `-n` needs extra stat() syscalls and thus a bit slower.

0.24user 0.06system 0:00.51elapsed 59%CPU (0avgtext+0avgdata 66916maxresident)k
8inputs+8040outputs (0major+15523minor)pagefaults 0swaps
Comment by Andreas Radke (AndyRTR) - Monday, 18 May 2020, 08:22 GMT
Package version 2.0+1+g6bf9e4f-2 runs now "/usr/bin/env PKGSYSTEM_ENABLE_FSYNC=0 /usr/bin/update-mime-database /usr/share/mime" without the additional "-n" option
and should bring back old fast behavior.
Comment by Chih-Hsuan Yen (yan12125) - Monday, 18 May 2020, 10:52 GMT
I can confirm the fix. Thanks a lot!

Loading...