How it the performance compared to Cairo/Pixman?
So at this point… not so great. With some caveats!
I did up some benchmarks with zBench this morning just to check. Every now and then I test the performance with poop
- I’ll get to that in a second, but the zBench benchmarks will likely be more realistic because we want to track the actual operations without the load time or dynamic linker overhead.
Here’s the results on the logomark README test:
So we’re looking at around 20x worse on default AA, but only about 10x with AA disabled. Funny enough if you’re exporting, things jump a lot (and we actually beat Cairo!). Not too sure what’s going on there, if it’s indicative of libpng performance or something else I’m missing.
Now to illustrate the caveats, here’s the poop
output for my default case (no export, default AA):
Quite different.
This shows probably the biggest advantage of using z2d currently over something like Cairo or Pixman - no C dependencies or external libraries, just pure Zig and static linking.
Performance is something I’ll be able to work on a lot more as the feature set matures. I made pretty big inroads in 0.6.0 as most compositor operations are now vectorized, but as we become more feature complete (especially once text support lands) this is something that will get more attention!
Appendix A: Allocator choice
Thinking about certain factors that could affect the benchmark after I posted this, I decided to run the benchmark again, but using c_allocator
instead of SmpAllocator
. Interesting results:
This drops the performance loss down to only around 10x for default AA and 8x for no AA.
So there’s obviously some other factors that are going to affect your mileage here, the test is not going to be 1:1 at all, and being 1:1 may not be what you actually want; using the C allocator gives you a dependency on libc, with regards to this one example. Again, at the moment, the true benefit to using z2d over something like Cairo or Pixman is the fact that’s it’s pure Zig.