# Help wanted to track down a Cairo.jl problem

**URL:** <https://discourse.julialang.org/t/help-wanted-to-track-down-a-cairo-jl-problem/19738>\
**Category:** General Usage\
**Created:** [January 17, 2019, 9:33am UTC](https://discourse.julialang.org/t/help-wanted-to-track-down-a-cairo-jl-problem/19738 "2019-01-17T09:33:52Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)\
**Post date:** [January 17, 2019, 9:33am UTC](https://discourse.julialang.org/t/help-wanted-to-track-down-a-cairo-jl-problem/19738/1 "2019-01-17T09:33:52Z")

</div>

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:

```julia
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… 🙂

---

<div class="post-metadata">

**Author:** ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)\
**Post date:** [January 17, 2019, 10:49am UTC](https://discourse.julialang.org/t/help-wanted-to-track-down-a-cairo-jl-problem/19738/2 "2019-01-17T10:49:47Z")

</div>

On Linux and Julia 1.0.3:

```julia
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
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)

```

---

<div class="post-metadata">

**Author:** ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)\
**Post date:** [January 17, 2019, 10:54am UTC](https://discourse.julialang.org/t/help-wanted-to-track-down-a-cairo-jl-problem/19738/3 "2019-01-17T10:54:23Z")

</div>

Linux times are looking good…

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [January 17, 2019, 11:46am UTC](https://discourse.julialang.org/t/help-wanted-to-track-down-a-cairo-jl-problem/19738/4 "2019-01-17T11:46:46Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)\
**Post date:** [January 17, 2019, 11:48am UTC](https://discourse.julialang.org/t/help-wanted-to-track-down-a-cairo-jl-problem/19738/5 "2019-01-17T11:48:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![tobias.knopp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tobias.knopp/32/7551_2.png) [@tobias.knopp](https://discourse.julialang.org/u/tobias.knopp)\
**Post date:** [January 17, 2019, 11:59am UTC](https://discourse.julialang.org/t/help-wanted-to-track-down-a-cairo-jl-problem/19738/6 "2019-01-17T11:59:45Z")

</div>

I get

```julia
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.

---

<div class="post-metadata">

**Author:** ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)\
**Post date:** [January 17, 2019, 12:12pm UTC](https://discourse.julialang.org/t/help-wanted-to-track-down-a-cairo-jl-problem/19738/7 "2019-01-17T12:12:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)\
**Post date:** [January 17, 2019, 3:16pm UTC](https://discourse.julialang.org/t/help-wanted-to-track-down-a-cairo-jl-problem/19738/8 "2019-01-17T15:16:36Z")

</div>

```julia
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)

```

---

<div class="post-metadata">

**Author:** ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)\
**Post date:** [January 17, 2019, 3:50pm UTC](https://discourse.julialang.org/t/help-wanted-to-track-down-a-cairo-jl-problem/19738/9 "2019-01-17T15:50:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![goedman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goedman/32/217_2.png) [@goedman](https://discourse.julialang.org/u/goedman)\
**Post date:** [January 17, 2019, 4:53pm UTC](https://discourse.julialang.org/t/help-wanted-to-track-down-a-cairo-jl-problem/19738/10 "2019-01-17T16:53:22Z")

</div>

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(R) 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

---

<div class="post-metadata">

**Author:** ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)\
**Post date:** [January 17, 2019, 4:55pm UTC](https://discourse.julialang.org/t/help-wanted-to-track-down-a-cairo-jl-problem/19738/11 "2019-01-17T16:55:57Z")

</div>

That’s so quick it looks odd. Thanks.

---

<div class="post-metadata">

**Author:** ![goedman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goedman/32/217_2.png) [@goedman](https://discourse.julialang.org/u/goedman)\
**Post date:** [January 17, 2019, 5:01pm UTC](https://discourse.julialang.org/t/help-wanted-to-track-down-a-cairo-jl-problem/19738/12 "2019-01-17T17:01:47Z")

</div>

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(R) Core™ i5-6267U CPU @ 2.90GHz  
WORD\_SIZE: 64  
LIBM: libopenlibm  
LLVM: libLLVM-6.0.1 (ORCJIT, skylake)

---

<div class="post-metadata">

**Author:** ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)\
**Post date:** [January 17, 2019, 5:04pm UTC](https://discourse.julialang.org/t/help-wanted-to-track-down-a-cairo-jl-problem/19738/13 "2019-01-17T17:04:23Z")

</div>

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. 😀

---

<div class="post-metadata">

**Author:** ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)\
**Post date:** [January 17, 2019, 6:04pm UTC](https://discourse.julialang.org/t/help-wanted-to-track-down-a-cairo-jl-problem/19738/14 "2019-01-17T18:04:40Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![BenjaminBorn](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/benjaminborn/32/4910_2.png) [@BenjaminBorn](https://discourse.julialang.org/u/BenjaminBorn)\
**Post date:** [January 17, 2019, 6:51pm UTC](https://discourse.julialang.org/t/help-wanted-to-track-down-a-cairo-jl-problem/19738/15 "2019-01-17T18:51:03Z")

</div>

```julia
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)

```

---

<div class="post-metadata">

**Author:** ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)\
**Post date:** [January 17, 2019, 6:58pm UTC](https://discourse.julialang.org/t/help-wanted-to-track-down-a-cairo-jl-problem/19738/16 "2019-01-17T18:58:24Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![BenjaminBorn](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/benjaminborn/32/4910_2.png) [@BenjaminBorn](https://discourse.julialang.org/u/BenjaminBorn)\
**Post date:** [January 17, 2019, 7:12pm UTC](https://discourse.julialang.org/t/help-wanted-to-track-down-a-cairo-jl-problem/19738/17 "2019-01-17T19:12:45Z")

</div>

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

```julia
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)

```

---

<div class="post-metadata">

**Author:** ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)\
**Post date:** [January 17, 2019, 7:13pm UTC](https://discourse.julialang.org/t/help-wanted-to-track-down-a-cairo-jl-problem/19738/18 "2019-01-17T19:13:57Z")

</div>

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