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

Write colorbuffer directly to io if it fits in format #4475

Merged
merged 2 commits into from
Oct 14, 2024

Conversation

jkrumbiegel
Copy link
Member

@jkrumbiegel jkrumbiegel commented Oct 12, 2024

Noticed with @profview that record seemed to spend quite a bit of time in a copy! call. As this might not be necessary under many circumstances, I've added a branch that avoids copy!, leading to a nice speedup of about 20% in this simple example:

using GLMakie

# before
julia> @time record(lines(cumsum(randn(1000))), "test.mp4", 1:1000, framerate = 60) do i
       end
  6.611545 seconds (1.05 M allocations: 38.077 MiB, 0.24% gc time, 0.28% compilation time)

# after
julia> @time record(lines(cumsum(randn(1000))), "test.mp4", 1:1000, framerate = 60) do i
       end
  5.553962 seconds (1.05 M allocations: 37.878 MiB, 0.33% compilation time)
"test.mp4"

@MakieBot
Copy link
Collaborator

MakieBot commented Oct 12, 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 5.03s (4.97, 5.07) 0.04+- 108.72ms (107.54, 110.13) 0.84+- 580.91ms (409.70, 657.38) 116.58+- 8.48ms (8.45, 8.51) 0.02+- 25.71ms (25.63, 25.87) 0.09+-
master 5.07s (5.00, 5.16) 0.05+- 108.16ms (107.51, 108.76) 0.54+- 613.62ms (410.02, 653.70) 89.84+- 8.28ms (8.20, 8.37) 0.05+- 25.71ms (25.58, 26.12) 0.20+-
evaluation 1.01x invariant, -0.03s (-0.76d, 0.19p, 0.04std) 0.99x invariant, 0.56ms (0.78d, 0.17p, 0.69std) 1.06x noisy🤷‍♀️, -32.71ms (-0.31d, 0.57p, 103.21std) 0.98x slower X, 0.2ms (4.81d, 0.00p, 0.04std) 1.00x invariant, -0.0ms (-0.01d, 0.99p, 0.14std)
CairoMakie 4.87s (4.83, 4.91) 0.03+- 109.92ms (109.35, 110.99) 0.54+- 166.96ms (166.38, 167.51) 0.38+- 9.40ms (9.13, 9.60) 0.22+- 1.22ms (1.17, 1.24) 0.02+-
master 4.84s (4.80, 4.89) 0.03+- 113.14ms (109.29, 118.40) 4.45+- 167.43ms (167.11, 168.07) 0.32+- 9.21ms (8.98, 9.51) 0.21+- 1.19ms (1.14, 1.24) 0.04+-
evaluation 0.99x slower X, 0.04s (1.23d, 0.04p, 0.03std) 1.03x invariant, -3.22ms (-1.02d, 0.10p, 2.50std) 1.00x faster ✓, -0.47ms (-1.33d, 0.03p, 0.35std) 0.98x invariant, 0.19ms (0.90d, 0.12p, 0.21std) 0.97x invariant, 0.03ms (1.01d, 0.09p, 0.03std)
WGLMakie 5.63s (5.52, 5.81) 0.13+- 113.38ms (110.10, 124.01) 4.95+- 4.76s (4.62, 5.04) 0.16+- 12.13ms (11.53, 14.11) 0.98+- 118.20ms (116.32, 120.08) 1.26+-
master 5.63s (5.53, 5.81) 0.12+- 112.84ms (109.51, 117.72) 3.58+- 5.08s (4.90, 5.45) 0.19+- 12.01ms (11.61, 12.73) 0.45+- 120.23ms (118.70, 123.06) 1.49+-
evaluation 1.00x invariant, -0.0s (-0.02d, 0.97p, 0.12std) 1.00x invariant, 0.54ms (0.13d, 0.82p, 4.27std) 1.07x faster✅, -0.32s (-1.80d, 0.01p, 0.18std) 0.99x invariant, 0.12ms (0.16d, 0.77p, 0.72std) 1.02x faster ✓, -2.02ms (-1.47d, 0.02p, 1.38std)

@jkrumbiegel jkrumbiegel merged commit e74adcb into master Oct 14, 2024
18 checks passed
@jkrumbiegel jkrumbiegel deleted the jk/video-render-optimization branch October 14, 2024 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Merged
Development

Successfully merging this pull request may close these issues.

3 participants