AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / unix / 问题 / 532011
Accepted
Nathaniel M. Beaver
Nathaniel M. Beaver
Asked: 2019-07-25 20:05:45 +0800 CST2019-07-25 20:05:45 +0800 CST 2019-07-25 20:05:45 +0800 CST

调试缓慢的缩略图进程

  • 772

我正在尝试在缩略图生成过程中调试一种特殊的性能行为eog,特别是gdk-pixbuf. 要重现的最小文件在这里:

https://github.com/nbeaver/gdk-pixbuf-bug

进程树如下所示:

systemd,1 splash
  `-plasmashell,4366
      `-konsole,6783
          `-bash,6793
              `-make,6949 reproduce
                  `-eog,6973 /usr/share/doc/docutils-doc/docs/user/images
                      `-bwrap,10071 --ro-bind /usr /usr --ro-bind /bin /bin --ro-bind /lib64 /lib64 --ro-bind /lib /lib --ro-bind /sbin /sbin --proc /proc --dev /dev --chdir / --setenv GIO_USE_VFS local --unshare-all --die-with-parent --bind /tmp/gnome-desktop-thumbnailer-2HUN5Z /tmp --ro-bind /usr/share/doc/docutils-doc/docs/user/images/s5-files.svg /tmp/gnome-desktop-file-to-thumbnail.svg --seccomp 11 /usr/bin/gdk-pixbuf-thumbnailer -s 128 file:///tmp/gnome-desktop-file-to-thumbnail.svg /tmp/gnome-desktop-thumbnailer.png
                          `-bwrap,10074 --ro-bind /usr /usr --ro-bind /bin /bin --ro-bind /lib64 /lib64 --ro-bind /lib /lib --ro-bind /sbin /sbin --proc /proc --dev /dev --chdir / --setenv GIO_USE_VFS local --unshare-all --die-with-parent --bind /tmp/gnome-desktop-thumbnailer-2HUN5Z /tmp --ro-bind /usr/share/doc/docutils-doc/docs/user/images/s5-files.svg /tmp/gnome-desktop-file-to-thumbnail.svg --seccomp 11 /usr/bin/gdk-pixbuf-thumbnailer -s 128 file:///tmp/gnome-desktop-file-to-thumbnail.svg /tmp/gnome-desktop-thumbnailer.png
                              `-gdk-pixbuf-thum,10075 -s 128 file:///tmp/gnome-desktop-file-to-thumbnail.svg /tmp/gnome-desktop-thumbnailer.png

从strace日志中,看起来/usr/bin/gdk-pixbuf-thumbnailer大约需要 30 秒查看字体文件:

22:44:05 munmap(0x7fd491988000, 20930832) = 0 <0.000558>
22:44:05 openat(AT_FDCWD, "/usr/share/fonts/opentype/noto/NotoSansCJK-Bold.ttc", O_RDONLY) = 5 <0.000060>
22:44:05 fcntl(5, F_SETFD, FD_CLOEXEC)  = 0 <0.000014>
22:44:05 fstat(5, {st_mode=S_IFREG|0644, st_size=20930832, ...}) = 0 <0.000013>
22:44:05 mmap(NULL, 20930832, PROT_READ, MAP_PRIVATE, 5, 0) = 0x7fd491988000 <0.000021>
22:44:05 close(5)                       = 0 <0.000011>
22:44:06 munmap(0x7fd491988000, 20930832) = 0 <0.000525>
22:44:06 openat(AT_FDCWD, "/usr/share/fonts/opentype/noto/NotoSansCJK-Bold.ttc", O_RDONLY) = 5 <0.000076>
22:44:06 fcntl(5, F_SETFD, FD_CLOEXEC)  = 0 <0.000013>
22:44:06 fstat(5, {st_mode=S_IFREG|0644, st_size=20930832, ...}) = 0 <0.000012>
22:44:06 mmap(NULL, 20930832, PROT_READ, MAP_PRIVATE, 5, 0) = 0x7fd491988000 <0.000023>
22:44:06 close(5)                       = 0 <0.000013>
<snip>
22:44:31 stat("/usr/share/fonts/opentype/stix-word/STIXMath-Regular.otf", {st_mode=S_IFREG|0644, st_size=476872, ...}) = 0 <0.000024>
22:44:31 openat(AT_FDCWD, "/usr/share/fonts/opentype/stix-word/STIXMath-Regular.otf", O_RDONLY) = 5 <0.000026>
22:44:31 fcntl(5, F_SETFD, FD_CLOEXEC)  = 0 <0.000014>
22:44:31 fstat(5, {st_mode=S_IFREG|0644, st_size=476872, ...}) = 0 <0.000013>
22:44:31 mmap(NULL, 476872, PROT_READ, MAP_PRIVATE, 5, 0) = 0x7fd49c26a000 <0.000023>
22:44:31 close(5)                       = 0 <0.000015>

有一个特定的 SVG 会触发此行为。但是,仅在 SVG 上运行eog 或运行是不够的。gdk-pixbuf-thumbnailer此行为仅在以下情况下发生:

  • 在目录上运行eog;

  • 目录中有一个特定的 SVG,但~/.cache/thumbnails/.

    (我touch用来更新 SVG 的时间戳并让缩略图每次都再次运行。)

  • 在同一目录中至少有一个其他图像;

  • 另一个图像的文件名在 SVG 文件名之前进行整理。

    (如果文件名在 SVG 文件名之后排序,它会在不到一秒的时间内生成缩略图。否则大约需要 30 秒。)

还有一些其他的谜题。在strace日志中,挂钟时间似乎与系统调用所花费的时间不匹配。我已经在旗帜eog下奔跑:strace-f

-f

由于 fork(2)、vfork(2) 和 clone(2) 系统调用由当前跟踪的进程创建,因此跟踪子进程。

我也尝试过这个-ff标志:

-ff

如果该-o filename选项有效,则每个进程跟踪都将写入每个进程 的数字进程 IDfilename.pid所在的位置。pid

但在任何一种情况下 gdk-pixbuf-thumbnailer都不会出现在子进程的日志文件中。

我也无法运行(gdb关于gdk-pixbuf-thumbnailer “目标和调试器位于不同的 PID 命名空间”),所以我不知道它卡在哪里了。

$ sudo gdb -p 20789
[sudo] password for nathaniel:
<snip>
Error while mapping shared library sections:
Could not open `target:/lib/x86_64-linux-gnu/libbsd.so.0' as an executable file: No such file or directory

warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.

warning: Target and debugger are in different PID namespaces; thread lists and other data are likely unreliable.  Connect to gdbserver inside the container.
(gdb) quit
Detaching from program: target:/newroot/usr/bin/gdk-pixbuf-thumbnailer, process 20789

我猜这与bwrap容器有关。

版本信息:

$ apt-cache policy libgdk-pixbuf2.0-bin eog
libgdk-pixbuf2.0-bin:
  Installed: 2.36.11-2
  Candidate: 2.36.11-2
  Version table:
 *** 2.36.11-2 500
        500 http://us.archive.ubuntu.com/ubuntu bionic/main amd64 Packages
        100 /var/lib/dpkg/status
eog:
  Installed: 3.28.1-1
  Candidate: 3.28.1-1
  Version table:
 *** 3.28.1-1 500
        500 http://us.archive.ubuntu.com/ubuntu bionic/main amd64 Packages
        100 /var/lib/dpkg/status

我的问题是:

  • 这个错误可以在其他机器和其他版本上重现吗?

    (我碰巧使用的是 Ubuntu 18.04,但我想知道这是否发生在其他发行版上。)

  • 为什么不 作为子进程strace -f拾取?/usr/bin/gdk-pixbuf-thumbnailereog

    是否eog使用不寻常的方法来创建子进程?

  • 如何使用gdb附加到 /usr/bin/gdk-pixbuf-thumbnailer流程并查看它花费时间的功能?

  • 什么可能导致这种行为?

fonts strace
  • 1 1 个回答
  • 639 Views

1 个回答

  • Voted
  1. Best Answer
    Nathaniel M. Beaver
    2019-07-26T08:51:27+08:002019-07-26T08:51:27+08:00

    在找到正确的网络搜索关键字组合后,我 90% 确定这是 2018 年 12 月 15 日此错误的重复:

    由于字体问题,缩略图生成缓慢

    因此,我正在调查自动重新加载 SVG 文件时 eog 的减速,似乎问题出在缩略图生成中,这需要大约 10 秒。(对于一个小的 SVG,请注意。)更具体地说,gdk-pixbuf-thumbnailer 抱怨找不到字体配置并花了很多时间查看字体。添加--ro-bind /var/cache/fontconfig /var/cache/fontconfigbwrap 的参数解决了这个问题,时间减少到 ~0.2 秒。

    https://gitlab.gnome.org/GNOME/gnome-desktop/issues/90

    这里提到:

    ...而且我们的速度也大幅放缓,请参阅 https://gitlab.gnome.org/GNOME/gnome-desktop/issues/90

    https://bugs.launchpad.net/ubuntu/+source/gnome-desktop3/+bug/1795668

    修复是gnome-desktop3.

    thumbnail:修复了由于缺少字体缓存而导致的慢速缩略图

    在某些发行版中,字体缓存并不存在于 /usr 中,而是存在于 /var 中,我们不允许在沙箱化缩略图时访问它。如果 fontconfig 缓存目录位于 /usr 之外,则以只读方式绑定挂载,以加快缩略图启动。

    https://gitlab.gnome.org/GNOME/gnome-desktop/merge_requests/25/diffs

    看起来修复是在 gnome-desktop3 版本 3.30 及更高版本中,所以截至 2019 年 7 月 19 日,只有 Ubuntu 19.10(Eoan Ermine,未发布)和 19.04(Disco Dingo,2020 年 1 月生命周期结束)。

    https://launchpad.net/ubuntu/+source/gnome-desktop3

    https://launchpad.net/ubuntu/+source/gnome-desktop3/+publishinghistory

    我的机器的版本信息:

    $ apt-cache policy libgnome-desktop-3-17
    libgnome-desktop-3-17:
      Installed: 3.28.2-0ubuntu1.5
      Candidate: 3.28.2-0ubuntu1.5
      Version table:
     *** 3.28.2-0ubuntu1.5 500
            500 http://us.archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages
            100 /var/lib/dpkg/status
         3.28.2-0ubuntu1.3 500
            500 http://security.ubuntu.com/ubuntu bionic-security/main amd64 Packages
         3.28.1-1ubuntu1 500
            500 http://us.archive.ubuntu.com/ubuntu bionic/main amd64 Packages
    
    • 1

相关问题

  • 如何确定延迟是由驱动程序还是调度程序引起的?

  • 如何为 CentOS 7 安装字体?

  • 可以使用 getauxval 来确定您是否被追踪吗?

  • 某些文本在 Google Chrome 中字体错误且未对齐

  • 这张图片中的字体是什么?[关闭]

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    模块 i915 可能缺少固件 /lib/firmware/i915/*

    • 3 个回答
  • Marko Smith

    无法获取 jessie backports 存储库

    • 4 个回答
  • Marko Smith

    如何将 GPG 私钥和公钥导出到文件

    • 4 个回答
  • Marko Smith

    我们如何运行存储在变量中的命令?

    • 5 个回答
  • Marko Smith

    如何配置 systemd-resolved 和 systemd-networkd 以使用本地 DNS 服务器来解析本地域和远程 DNS 服务器来解析远程域?

    • 3 个回答
  • Marko Smith

    dist-upgrade 后 Kali Linux 中的 apt-get update 错误 [重复]

    • 2 个回答
  • Marko Smith

    如何从 systemctl 服务日志中查看最新的 x 行

    • 5 个回答
  • Marko Smith

    Nano - 跳转到文件末尾

    • 8 个回答
  • Marko Smith

    grub 错误:你需要先加载内核

    • 4 个回答
  • Marko Smith

    如何下载软件包而不是使用 apt-get 命令安装它?

    • 7 个回答
  • Martin Hope
    user12345 无法获取 jessie backports 存储库 2019-03-27 04:39:28 +0800 CST
  • Martin Hope
    Carl 为什么大多数 systemd 示例都包含 WantedBy=multi-user.target? 2019-03-15 11:49:25 +0800 CST
  • Martin Hope
    rocky 如何将 GPG 私钥和公钥导出到文件 2018-11-16 05:36:15 +0800 CST
  • Martin Hope
    Evan Carroll systemctl 状态显示:“状态:降级” 2018-06-03 18:48:17 +0800 CST
  • Martin Hope
    Tim 我们如何运行存储在变量中的命令? 2018-05-21 04:46:29 +0800 CST
  • Martin Hope
    Ankur S 为什么 /dev/null 是一个文件?为什么它的功能不作为一个简单的程序来实现? 2018-04-17 07:28:04 +0800 CST
  • Martin Hope
    user3191334 如何从 systemctl 服务日志中查看最新的 x 行 2018-02-07 00:14:16 +0800 CST
  • Martin Hope
    Marko Pacak Nano - 跳转到文件末尾 2018-02-01 01:53:03 +0800 CST
  • Martin Hope
    Kidburla 为什么真假这么大? 2018-01-26 12:14:47 +0800 CST
  • Martin Hope
    Christos Baziotis 在一个巨大的(70GB)、一行、文本文件中替换字符串 2017-12-30 06:58:33 +0800 CST

热门标签

linux bash debian shell-script text-processing ubuntu centos shell awk ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve