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

Fix camera observable caching and cleanup #3640

Closed
wants to merge 6 commits into from
Closed

Conversation

ffreyer
Copy link
Collaborator

@ffreyer ffreyer commented Feb 19, 2024

Description

Fixes #3639 by

  • detaching the cached scaled resolution from plot to avoid plot based cleanup
  • adding a dublication observable to avoid robj based cleanup

Changes to camera matrix caching

The calculation of cached matrices depends on existing matrices in scene.camera which are unrelated to the plot or renderobject, and on plot.space which may change dynamically. Therefore cached camera matrices

  • must use a static space
  • must not get deleted when a plot or renderobject is deleted
  • must be created dynamically based on the plots space

TODO:

  • re-enable camera matrix caching
  • check WGLMakie
  • add tests

Type of change

Delete options that do not apply:

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

Checklist

  • Added an entry in NEWS.md (for new features and breaking changes)
  • Added or changed relevant sections in the documentation
  • Added unit tests for new algorithms, conversion methods, etc.
  • Added reference image tests for new plotting functions, recipes, visual options, etc.

@MakieBot
Copy link
Collaborator

MakieBot commented Feb 19, 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 3.33s (3.30, 3.36) 0.02+- 380.82ms (378.25, 382.63) 1.72+- 470.67ms (463.43, 505.85) 15.53+- 6.96ms (6.86, 7.02) 0.07+- 25.25ms (25.16, 25.34) 0.07+-
master 3.32s (3.30, 3.35) 0.02+- 392.59ms (389.81, 395.16) 2.01+- 465.76ms (461.49, 469.78) 2.97+- 7.04ms (6.92, 7.10) 0.06+- 25.22ms (25.09, 25.30) 0.07+-
evaluation 1.00x invariant, 0.01s (0.46d, 0.41p, 0.02std) 1.03x faster ✓, -11.77ms (-6.30d, 0.00p, 1.86std) 0.99x invariant, 4.92ms (0.44d, 0.44p, 9.25std) 1.01x faster ✓, -0.08ms (-1.18d, 0.05p, 0.06std) 1.00x invariant, 0.04ms (0.55d, 0.32p, 0.07std)
CairoMakie 3.12s (2.99, 3.22) 0.08+- 337.51ms (320.83, 350.21) 10.32+- 150.37ms (141.71, 157.99) 5.98+- 7.65ms (7.16, 8.04) 0.27+- 621.99μs (618.13, 626.55) 3.00+-
master 3.15s (3.09, 3.19) 0.03+- 339.63ms (331.35, 361.43) 10.10+- 153.36ms (142.81, 176.00) 10.84+- 7.76ms (7.48, 7.90) 0.14+- 619.28μs (617.63, 621.03) 1.13+-
evaluation 1.01x invariant, -0.03s (-0.55d, 0.34p, 0.06std) 1.01x invariant, -2.11ms (-0.21d, 0.71p, 10.21std) 1.02x invariant, -2.99ms (-0.34d, 0.54p, 8.41std) 1.01x invariant, -0.11ms (-0.50d, 0.38p, 0.21std) 1.00x invariant, 2.71μs (1.19d, 0.06p, 2.06std)
WGLMakie 3.83s (3.80, 3.87) 0.03+- 336.52ms (331.28, 341.39) 4.17+- 9.42s (9.25, 9.62) 0.15+- 9.71ms (9.48, 9.84) 0.16+- 69.25ms (67.98, 70.80) 0.97+-
master 3.83s (3.80, 3.86) 0.03+- 340.03ms (327.89, 347.06) 7.30+- 9.38s (9.27, 9.50) 0.07+- 10.07ms (9.55, 12.13) 0.91+- 69.08ms (68.48, 70.13) 0.58+-
evaluation 1.00x invariant, 0.0s (0.10d, 0.85p, 0.03std) 1.01x invariant, -3.51ms (-0.59d, 0.30p, 5.73std) 1.00x invariant, 0.04s (0.36d, 0.52p, 0.11std) 1.04x invariant, -0.36ms (-0.55d, 0.34p, 0.54std) 1.00x invariant, 0.18ms (0.22d, 0.69p, 0.78std)

@ffreyer ffreyer changed the title fix #3639 Fix camera observable caching and cleanup Feb 19, 2024
@ffreyer ffreyer marked this pull request as ready for review February 19, 2024 18:13
@ffreyer
Copy link
Collaborator Author

ffreyer commented Feb 20, 2024

Hmm, I'm getting more allocations with this than master... Was this actually useful when you added it @SimonDanisch?

@ffreyer ffreyer closed this Mar 18, 2024
@ffreyer ffreyer deleted the camera_caching_fixes branch March 18, 2024 12:34
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.

Lines and text scale weirdly after emptying axis, adding new plot, and rescaling figure
3 participants