Slow execution on Mac M1

Hello,

I noticed that calling dot on my new M1 is quite slow.

On my old Intel Mac (Core Duo from 2009) the test results in about 150ms execution time.
The installed dot version is 2.42.2. Btw. this is the time also measure on a FreeBSD box.

With my iMac M1 there is a noticeable delay. Call with the same dot file takes about 350-450ms.
Installed dot version is 2.47.3

The test I use:
gdate +%N; dot -Tpng -o test.png -Tjson -o test.json test.dot; gdate +%N

Is this something others also see? Otherwise I don’t notice that my new M1 is slower. The opposite is the case. Installing and compiling brew packages for example is much much faster.

Any hint what I can try out is very welcome.

Dot is using this libraries:

/opt/homebrew/Cellar/graphviz/2.47.3/lib/libgvc.6.dylib (compatibility version 7.0.0, current version 7.0.0)
/opt/homebrew/opt/libtool/lib/libltdl.7.dylib (compatibility version 11.0.0, current version 11.1.0)
/opt/homebrew/Cellar/graphviz/2.47.3/lib/libxdot.4.dylib (compatibility version 5.0.0, current version 5.0.0)
/opt/homebrew/Cellar/graphviz/2.47.3/lib/libcgraph.6.dylib (compatibility version 7.0.0, current version 7.0.0)
/opt/homebrew/Cellar/graphviz/2.47.3/lib/libpathplan.4.dylib (compatibility version 5.0.0, current version 5.0.0)
/usr/lib/libexpat.1.dylib (compatibility version 7.0.0, current version 8.0.0)
/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.11)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1292.100.5)
/opt/homebrew/Cellar/graphviz/2.47.3/lib/libcdt.5.dylib (compatibility version 6.0.0, current version 6.0.0)

The version output is

dot -version
dot - graphviz version 2.47.3 (20210619.1520)
libdir = “/opt/homebrew/Cellar/graphviz/2.47.3/lib/graphviz”
Activated plugin library: libgvplugin_dot_layout.6.dylib
Using layout: dot:dot_layout
Activated plugin library: libgvplugin_core.6.dylib
Using render: dot:core
Using device: dot:dot:core
The plugin configuration file:
/opt/homebrew/Cellar/graphviz/2.47.3/lib/graphviz/config6
was successfully loaded.
render : cairo dot dot_json fig gd json json0 map mp pic pov ps quartz svg tk visio vml vrml xdot xdot_json
layout : circo dot fdp neato nop nop1 nop2 osage patchwork sfdp twopi
textlayout : textlayout
device : bmp canon cgimage cmap cmapx cmapx_np dot dot_json eps exr fig gd gd2 gif gv icns ico imap imap_np ismap jp2 jpe jpeg jpg json json0 mp pct pdf pic pict plain plain-ext png pov ps ps2 psd sgi svg svgz tga tif tiff tk vdx vml vmlz vrml wbmp webp xdot xdot1.2 xdot1.4 xdot_json
loadimage : (lib) bmp eps gd gd2 gif jpe jpeg jpg pdf png ps svg webp xbm

Thanks,
Peter

AFAIK Graphviz contains no x86-specific optimizations. This difference may be due to how Homebrew packages Graphviz. I do not know if they build Graphviz for the M1 or ship an x86-64 build and rely on emulation.

Hi,

it is built for M1: /opt/homebrew/bin/dot: Mach-O 64-bit executable arm64

What do you mean by “how they packages Graphviz”?

Any further help would be appreciated. Is there some sort of logging possible
which “part” inside dot takes how much time?

Thanks,
Peter

Hello,

on the brew list I got help and could build version 2.43.0 on my Mac M1

This is fast as before. dot job returns after about 100ms.

Has there been changes between 2.43 and 2.47.3 which might cause
this much longer execution time?

I believe Homebrew (and Macports) have some scripting to build Graphviz themselves, rather than relying on the pre-built macOS binaries the Graphviz project itself offers. I don’t know whether their compilation is done on end users machines or whether they ship a binary.

There’s -v that you can apply multiple times for increasing levels of verbose output. However, this is unlikely to be much help. I usually resort to profiling dot with something like Valgrind or perf. Some way to inspect the timing of various operations is certainly a common request from users, and it’s been something we’ve been discussing how to provide.

Has there been changes between 2.43 and 2.47.3 which might cause
this much longer execution time?

Nothing significant that I’m aware of, but the runtime of Graphviz is highly dependent on the input graph. If you can share your input, I can try profiling it on 2.43.0 vs 2.47.3. But I do not have access to an M1 Mac, so this would be on Linux.