Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve CairoMakie's 2D mesh performance #4132

Merged
merged 10 commits into from
Oct 22, 2024
Merged

Improve CairoMakie's 2D mesh performance #4132

merged 10 commits into from
Oct 22, 2024

Conversation

asinghvi17
Copy link
Member

Description

As seen in #4112, CairoMakie's 2D drawing routines are pretty slow. This PR attempts to speed them up a bit (currently has a ~30% improvement locally). Not done with the optimization or profiling yet though, and I have a sense that a lot of optimization is still doable.

Each change is usually a single commit so the commit log should show what's been done.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

@MakieBot
Copy link
Collaborator

MakieBot commented Aug 14, 2024

Compile Times benchmark

Note, that these numbers may fluctuate on the CI servers, so take them with a grain of salt. All benchmark results are based on the mean time and negative percent mean faster than the base branch. Note, that GLMakie + WGLMakie run on an emulated GPU, so the runtime benchmark is much slower. Results are from running:

using_time = @ctime using Backend
# Compile time
create_time = @ctime fig = scatter(1:4; color=1:4, colormap=:turbo, markersize=20, visible=true)
display_time = @ctime Makie.colorbuffer(display(fig))
# Runtime
create_time = @benchmark fig = scatter(1:4; color=1:4, colormap=:turbo, markersize=20, visible=true)
display_time = @benchmark Makie.colorbuffer(fig)
using create display create display
GLMakie 6.28s (6.14, 6.56) 0.12+- 162.02ms (157.57, 172.86) 4.43+- 470.59ms (462.70, 488.57) 6.82+- 6.78ms (6.69, 6.94) 0.07+- 25.74ms (25.42, 26.46) 0.29+-
master 6.30s (6.13, 6.69) 0.15+- 163.08ms (156.74, 177.50) 6.06+- 474.13ms (460.91, 504.48) 11.75+- 6.83ms (6.71, 7.28) 0.16+- 25.79ms (25.41, 26.56) 0.37+-
evaluation 1.00x invariant, -0.02s (-0.14d, 0.66p, 0.13std) 1.01x invariant, -1.05ms (-0.20d, 0.53p, 5.24std) 1.01x invariant, -3.54ms (-0.37d, 0.25p, 9.29std) 1.01x invariant, -0.05ms (-0.42d, 0.19p, 0.12std) 1.00x invariant, -0.05ms (-0.16d, 0.62p, 0.33std)
CairoMakie 5.92s (5.85, 6.01) 0.05+- 162.98ms (160.59, 169.14) 2.54+- 199.14ms (195.17, 206.62) 2.80+- 6.84ms (6.79, 6.95) 0.04+- 1.06ms (1.05, 1.07) 0.01+-
master 5.93s (5.85, 6.02) 0.05+- 163.95ms (159.78, 175.39) 3.65+- 199.26ms (196.00, 203.68) 1.88+- 6.78ms (6.68, 6.85) 0.05+- 1.06ms (1.05, 1.07) 0.01+-
evaluation 1.00x invariant, -0.01s (-0.17d, 0.60p, 0.05std) 1.01x invariant, -0.97ms (-0.31d, 0.34p, 3.09std) 1.00x invariant, -0.12ms (-0.05d, 0.88p, 2.34std) 0.99x slower X, 0.06ms (1.26d, 0.00p, 0.05std) 1.00x invariant, 0.0ms (0.09d, 0.79p, 0.01std)
WGLMakie 6.59s (6.47, 6.71) 0.05+- 164.97ms (160.05, 173.04) 3.70+- 5.61s (5.47, 5.93) 0.11+- 10.41ms (10.10, 10.80) 0.20+- 147.01ms (142.98, 156.44) 2.76+-
master 6.59s (6.49, 6.69) 0.05+- 166.61ms (160.57, 172.63) 3.87+- 5.87s (5.80, 5.96) 0.04+- 10.43ms (10.20, 10.89) 0.16+- 146.41ms (143.10, 148.94) 1.58+-
evaluation 1.00x invariant, 0.0s (0.02d, 0.96p, 0.05std) 1.01x invariant, -1.64ms (-0.43d, 0.18p, 3.78std) 1.05x faster ✓, -0.26s (-3.16d, 0.00p, 0.07std) 1.00x invariant, -0.02ms (-0.12d, 0.72p, 0.18std) 1.00x invariant, 0.61ms (0.27d, 0.40p, 2.17std)

@ffreyer
Copy link
Collaborator

ffreyer commented Oct 10, 2024

Should we merge this since nothing more has happened here? 30% is already quite significant (and the GeometryBasics refactor may change some details anyway)

@asinghvi17
Copy link
Member Author

Agreed, may as well merge. Will wait for the GeometryBasics refactor before pushing more on this! (And in the worst case, we can just switch all meshes to the 3d pipeline if it's significantly faster)

@asinghvi17 asinghvi17 marked this pull request as ready for review October 10, 2024 14:55
@asinghvi17 asinghvi17 changed the title [WIP] Improve CairoMakie's 2D mesh performance Improve CairoMakie's 2D mesh performance Oct 10, 2024
@asinghvi17 asinghvi17 self-assigned this Oct 10, 2024
@asinghvi17 asinghvi17 added the CairoMakie This relates to CairoMakie, the vector backend for Makie based on Cairo. label Oct 10, 2024
@asinghvi17
Copy link
Member Author

WGLMakie failures are because the texture atlas is slightly larger than expected:

session_size = 6.095909
texture_atlas_size = 6.095909
memory leaks: Test Failed at /home/runner/work/Makie.jl/Makie.jl/WGLMakie/test/runtests.jl:57
  Expression: texture_atlas_size < 6
   Evaluated: 6.095909 < 6
Stacktrace:
 [1] macro expansion
   @ ~/work/Makie.jl/Makie.jl/WGLMakie/test/runtests.jl:57 [inlined]
 [2] macro expansion
   @ /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/Test/src/Test.jl:1151 [inlined]
 [3] top-level scope
   @ ~/work/Makie.jl/Makie.jl/WGLMakie/test/runtests.jl:43
Test Summary: | Pass  Fail  Total
memory leaks  |    3     1      4
ERROR: LoadError: Some tests did not pass: 3 passed, 1 failed, 0 errored, 0 broken.
in expression starting at /home/runner/work/Makie.jl/Makie.jl/WGLMakie/test/runtests.jl:42
ERROR: Package WGLMakie errored during testing
Stacktrace:

@ffreyer ffreyer merged commit e3c7521 into master Oct 22, 2024
18 checks passed
@ffreyer ffreyer deleted the as/cairomesh2d branch October 22, 2024 00:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CairoMakie This relates to CairoMakie, the vector backend for Makie based on Cairo.
Projects
Status: Merged
Development

Successfully merging this pull request may close these issues.

4 participants