Skip to content

Slow rendering on FreeBSD due to poppler/lcms2 #697

Description

@uqs

Steps to Reproduce

  1. Install and run FreeBSD
  2. Open a large PDF (comics, say 100MB+ in size)
  3. Observe very slow rendering and 1 thread busy for a long time rendering thumbnails for the side panel
  4. Same PDF on Arch Linux renders speedily

Expected Behavior

Faster rendering, not so much CPU usage.

Actual Behavior

Slowness.

Error Output

Version

1.28.1 and latest main, but issue is several years old

Distribution

FreeBSD 14.4
Arch Linux

Additional Context

This is probably a poppler or lcms2 issue, but I don't know how to debug and profile this further.

Oddly, lcms on Arch seems to build without fast_float, while lcms2 on FreeBSD has it built in. If docs are correct though, the plugin must be loaded by the applications using cmsPlugin(cmsFastFloatExtensions()); which atril doesn't do.

Ok, so why is it slow? Profiling with pmcstat puts the blame here:

31.05%  [365428]   pow @ /lib/libm.so.5
 100.0%  [365428]    DefaultEvalParametricFn @ /usr/local/lib/liblcms2.so.2.0.19
  100.0%  [365428]     EvalSegmentedFn
   99.88%  [365006]      cmsEvalToneCurveFloat
    100.0%  [365006]       0x384c0
     100.0%  [365006]        _LUTeval16
      100.0%  [365006]         CachedXFORM
       100.0%  [365006]          cmsDoTransform
        100.0%  [365006]           _ZN17GfxColorTransform11doTransformEPvS0_j @ /usr/local/lib/libpoppler.so.159.0.0
         100.0%  [365006]            _ZN21GfxICCBasedColorSpace10getRGBLineEPhPji
          100.0%  [365006]             _ZN16GfxImageColorMap10getRGBLineEPhPji
           100.0%  [365006]              _ZN16RescaleDrawImage6getRowEiPj @ /usr/local/lib/libpoppler-glib.so.8.31.0
            100.0%  [365006]               _ZN16RescaleDrawImage14getSourceImageEP6StreamiiiibP16GfxImageColorMapPKi
             100.0%  [365006]                _ZN14CairoOutputDev9drawImageEP8GfxStateP6ObjectP6StreamiiP16GfxImageColorMapbPKib
              100.0%  [365006]                 _ZN3Gfx7doImageEP6ObjectP6Streamb @ /usr/local/lib/libpoppler.so.159.0.0
               100.0%  [365006]                  _ZN3Gfx9opXObjectEP6Objecti

[plus many more stacks involving _ZN21GfxICCBasedColorSpace10getRGBLineEPhPji and _ZN16GfxImageColorMap10getRGBLineEPhPji]

But I'm not sure how much to trust that profile. On Arch with perf cmsDoTransform hardly makes any appearance.

I don't care about color correctness at all, can I disable that ICC nonsense in any way? Why is this path even taken and does that path also happen for other Linux users (it's not my main system ...)

Reproducibility

Every time

Checklist

  • I have searched existing issues to avoid duplicates
  • I have provided all the requested information above

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions