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

CairoMakie allocations #3435

Merged
merged 6 commits into from
Dec 1, 2023
Merged

CairoMakie allocations #3435

merged 6 commits into from
Dec 1, 2023

Conversation

jkrumbiegel
Copy link
Member

Noticed that the speed of CairoMakie svg generation was sometimes really really slow. Turns out this was mostly because of the slow sha512 hashing, I replaced that with crc32 (it doesn't have to be cryptographically secure, just random enough to be practical). And I improved the id replacement and added some manual union splitting that also seemed to allocate quite a bit when drawing scatters.

Net result is drastic, but of course usually you wouldn't want the svg format anyway if you have many data points:

## before

julia> @time begin
           f = Figure()
           ax = Axis(f[1, 1])
           scatter!(ax, 1:10000)
           save("test2.svg", f)
       end;
 12.317504 seconds (444.40 k allocations: 125.444 MiB, 0.60% gc time)

## after

julia> @time begin
           f = Figure()
           ax = Axis(f[1, 1])
           scatter!(ax, 1:10000)
           save("test2.svg", f)
       end;
  0.100446 seconds (59.69 k allocations: 15.657 MiB)

@MakieBot
Copy link
Collaborator

MakieBot commented Dec 1, 2023

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 3.45s (3.41, 3.55) 0.05+- 337.15ms (305.41, 413.44) 45.61+- 479.84ms (468.00, 518.56) 18.42+- 7.56ms (7.41, 7.71) 0.11+- 25.97ms (25.55, 26.36) 0.34+-
master 3.48s (3.40, 3.59) 0.08+- 399.71ms (387.43, 413.99) 8.51+- 481.47ms (464.08, 494.20) 11.27+- 7.58ms (7.44, 7.69) 0.09+- 25.72ms (25.37, 26.46) 0.49+-
evaluation 1.01x invariant, -0.03s (-0.38d, 0.49p, 0.07std) 1.19x faster✅, -62.56ms (-1.91d, 0.01p, 27.06std) 1.00x invariant, -1.62ms (-0.11d, 0.85p, 14.85std) 1.00x invariant, -0.02ms (-0.22d, 0.69p, 0.10std) 0.99x invariant, 0.25ms (0.58d, 0.30p, 0.42std)
CairoMakie 3.03s (3.01, 3.08) 0.02+- 324.33ms (322.16, 329.41) 2.37+- 144.62ms (143.17, 146.56) 1.14+- 7.69ms (7.62, 7.85) 0.08+- 611.20μs (606.15, 614.27) 3.23+-
master 3.03s (3.01, 3.08) 0.03+- 329.89ms (323.76, 339.45) 5.16+- 145.30ms (143.12, 149.23) 2.67+- 7.99ms (7.88, 8.23) 0.11+- 604.21μs (598.89, 610.39) 3.98+-
evaluation 1.00x invariant, -0.0s (-0.00d, 1.00p, 0.02std) 1.02x faster ✓, -5.56ms (-1.39d, 0.03p, 3.76std) 1.00x invariant, -0.67ms (-0.33d, 0.56p, 1.91std) 1.04x faster ✓, -0.3ms (-2.97d, 0.00p, 0.10std) 0.99x slower X, 6.98μs (1.93d, 0.00p, 3.61std)
WGLMakie 3.75s (3.73, 3.78) 0.02+- 331.34ms (321.11, 346.18) 7.75+- 8.82s (8.74, 8.89) 0.06+- 9.84ms (9.38, 11.87) 0.90+- 75.43ms (67.60, 81.58) 5.50+-
master 3.71s (3.66, 3.78) 0.04+- 327.58ms (318.29, 334.62) 6.33+- 8.89s (8.56, 9.16) 0.20+- 9.52ms (9.40, 9.69) 0.11+- 73.78ms (68.31, 79.78) 5.11+-
evaluation 0.99x invariant, 0.04s (1.09d, 0.08p, 0.03std) 0.99x invariant, 3.76ms (0.53d, 0.34p, 7.04std) 1.01x invariant, -0.07s (-0.45d, 0.43p, 0.13std) 0.97x invariant, 0.32ms (0.49d, 0.39p, 0.51std) 0.98x invariant, 1.65ms (0.31d, 0.57p, 5.31std)

@SimonDanisch SimonDanisch merged commit e3777c2 into master Dec 1, 2023
15 checks passed
@SimonDanisch SimonDanisch deleted the jk/cairomakie-allocations branch December 1, 2023 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants