Help wanted to track down a Cairo.jl problem


#1

Could anyone with a few minutes to spare help me investigate a problem with Cairo on macOS/Linux?

Assuming you’ve installed Cairo successfully (and it’s been pre-compiled), run:

using Cairo
@time cr = CairoRGBSurface(256, 256)
@time c = CairoContext(cr)

and report the two times… So far the results I have are:

User Platform Julia Time1 Time2
cormullion macOS v0.6 0.0154 0.370006
cormullion macOS v1.0.2 0.104971 11.136036
cormullion macOS v1.1.0 0.008384 10.546599
lobingera Linux v1.0.2 0.013114 0.013396

The problem is that Cairo is very slow to get going on my Mac. First I want to know if it’s not just me… :slight_smile:


#2

On Linux and Julia 1.0.3:

julia> @time cr = CairoRGBSurface(256, 256)
  0.010506 seconds (21.43 k allocations: 1.072 MiB)
Cairo.CairoSurfaceBase{UInt32}(Ptr{Nothing} @0x0000000001552d00, 256.0, 256.0)

julia> @time c = CairoContext(cr)
  0.005270 seconds (9.57 k allocations: 538.150 KiB)
CairoContext(Ptr{Nothing} @0x00000000017a9730, Cairo.CairoSurfaceBase{UInt32}(Ptr{Nothing} @0x0000000001552d00, 256.0, 256.0), Ptr{Nothing} @0x000000000182e810)

on a5a58828df:

julia> @time cr = CairoRGBSurface(256, 256)
  0.011224 seconds (21.11 k allocations: 1.046 MiB)
Cairo.CairoSurfaceBase{UInt32}(Ptr{Nothing} @0x000055c42f49a0b0, 256.0, 256.0)

julia> @time c = CairoContext(cr)
  0.005561 seconds (9.76 k allocations: 540.729 KiB)
CairoContext(Ptr{Nothing} @0x000055c42f2ea580, Cairo.CairoSurfaceBase{UInt32}(Ptr{Nothing} @0x000055c42f49a0b0, 256.0, 256.0), Ptr{Nothing} @0x000055c42fa9e810)

#3

Linux times are looking good…


#4

On Windows 10, Julia 1.0.1 I get Time1 0.024187 seconds and Time2 0.041094 seconds


#5

Thanks, Windows doesn’t seem to have this problem either…


#6

I get

julia> @time cr = CairoRGBSurface(256, 256)
  0.011026 seconds (21.10 k allocations: 1.045 MiB)
Cairo.CairoSurfaceBase{UInt32}(Ptr{Nothing} @0x00007fc19e94a100, 256.0, 256.0)

julia> @time c = CairoContext(cr)
  0.570303 seconds (9.68 k allocations: 536.729 KiB)
CairoContext(Ptr{Nothing} @0x00007fc19c9cac00, Cairo.CairoSurfaceBase{UInt32}(Ptr{Nothing} @0x00007fc19e94a100, 256.0, 256.0), Ptr{Nothing} @0x00007fc19c9ad830)

on Mac on 1.1 and 1.0 timings are similar.


#7

Ah, that’s good to know (in a way!). :grinning:


#8
julia> using Cairo

julia> @time cr = CairoRGBSurface(256, 256)
  0.285513 seconds (21.10 k allocations: 1.045 MiB)
Cairo.CairoSurfaceBase{UInt32}(Ptr{Nothing} @0x00007fc0eb8fa500, 256.0, 256.0)

julia> @time c = CairoContext(cr)
  1.812419 seconds (9.68 k allocations: 536.729 KiB)
CairoContext(Ptr{Nothing} @0x00007fc0e9b72e00, Cairo.CairoSurfaceBase{UInt32}(Ptr{Nothing} @0x00007fc0eb8fa500, 256.0, 256.0), Ptr{Nothing} @0x00007fc0e9b9e010)

julia> versioninfo()
Julia Version 1.1.0-rc2.0
Commit 980eda064e (2019-01-13 00:19 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin14.5.0)
  CPU: Intel(R) Core(TM) i7-5557U CPU @ 3.10GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.1 (ORCJIT, broadwell)

#9

Ah, that’s quite slow-ish. Not 10 seconds slow, but nowhere near 0.005 seconds quick. The plot thickens…


#10

After a rebuild, a REPL restart and recompiling first:

julia> using Cairo

julia> @time cr = CairoRGBSurface(256, 256)

0.000016 seconds (5 allocations: 192 bytes)

Cairo.CairoSurfaceBase{UInt32}(Ptr{Nothing} @0x00007fa873c8bd20, 256.0, 256.0)

julia> @time c = CairoContext(cr)

0.000020 seconds (5 allocations: 192 bytes)

CairoContext(Ptr{Nothing} @0x00007fa874274800, Cairo.CairoSurfaceBase{UInt32}(Ptr{Nothing} @0x00007fa873c8bd20, 256.0, 256.0), Ptr{Nothing} @0x00007fa8748540d0)

julia> versioninfo()

Julia Version 1.1.0-rc2.0

Commit 980eda064e (2019-01-13 00:19 UTC)

Platform Info:

OS: macOS (x86_64-apple-darwin14.5.0)

CPU: Intel® Core™ i5-6267U CPU @ 2.90GHz

WORD_SIZE: 64

LIBM: libopenlibm

LLVM: libLLVM-6.0.1 (ORCJIT, skylake)

Environment:

JULIA_PKG3_PRECOMPILE = true

JULIA_CMDSTAN_HOME = /Users/rob/Projects/StanSupport/cmdstan

JULIA_EDITOR = see

JULIA_SVG_BROWSER = Google Chrome.app

JULIA_SPECIALFUNCTIONS_BUILD_SOURCE = true


#11

That’s so quick it looks odd. Thanks.


#12

Do you need the initial time, after a REPL restart?

Initial results:

julia> using Cairo

julia> @time cr = CairoRGBSurface(256, 256)

0.009780 seconds (21.11 k allocations: 1.050 MiB)

Cairo.CairoSurfaceBase{UInt32}(Ptr{Nothing} @0x00007fb322fa3570, 256.0, 256.0)

julia> @time c = CairoContext(cr)

0.397401 seconds (9.76 k allocations: 544.604 KiB)

CairoContext(Ptr{Nothing} @0x00007fb32413a600, Cairo.CairoSurfaceBase{UInt32}(Ptr{Nothing} @0x00007fb322fa3570, 256.0, 256.0), Ptr{Nothing} @0x00007fb323008020)

Second time around:

julia> using Cairo
julia> @time cr = CairoRGBSurface(256, 256)

0.000015 seconds (5 allocations: 192 bytes)

Cairo.CairoSurfaceBase{UInt32}(Ptr{Nothing} @0x00007fb3250f0ec0, 256.0, 256.0)

julia> @time c = CairoContext(cr)

0.000017 seconds (5 allocations: 192 bytes)

CairoContext(Ptr{Nothing} @0x00007fb32412b600, Cairo.CairoSurfaceBase{UInt32}(Ptr{Nothing} @0x00007fb3250f0ec0, 256.0, 256.0), Ptr{Nothing} @0x00007fb3230080d0)

Version info:

julia> versioninfo()

Julia Version 1.2.0-DEV.177
Commit ec807bc01c* (2019-01-17 05:33 UTC)

Platform Info:
OS: macOS (x86_64-apple-darwin18.2.0)
CPU: Intel® Core™ i5-6267U CPU @ 2.90GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-6.0.1 (ORCJIT, skylake)


#13

Thanks. I’m hoping to find at least one other person with times greater than 6 to 10 seconds, so that at least I’m not the only one suffering from this delay. :grinning:


#14

My current hypothesis is that Cairo startup time is proportional to how many fonts you have installed and active…


#15
julia> using Cairo

julia> @time cr = CairoRGBSurface(256, 256)
  0.007949 seconds (21.46 k allocations: 1.108 MiB)

julia> @time c = CairoContext(cr)
  0.274057 seconds (9.71 k allocations: 537.637 KiB, 1.87% gc time)

julia> versioninfo()
Julia Version 1.0.2
Commit d789231e99 (2018-11-08 20:11 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin14.5.0)
  CPU: Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.0 (ORCJIT, skylake)

#16

Thanks! You don’t have too many fonts installed, I suppose?


#17

“Unfortunately” not, sorry. And the second time I run it is then quite a bit faster

julia> @time cr = CairoRGBSurface(256, 256)
  0.000013 seconds (5 allocations: 192 bytes)

julia> @time c = CairoContext(cr)
  0.000016 seconds (5 allocations: 192 bytes)

#18

No, that’s good news… More fonts, slower start-up, I reckon…