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

Widget optimizations #4821

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from
Draft

Widget optimizations #4821

wants to merge 12 commits into from

Conversation

ffreyer
Copy link
Collaborator

@ffreyer ffreyer commented Feb 24, 2025

Description

This pr is somewhat in response of #4074 but not solely focused on it. There are mainly two types of changes here:

First is removing pick() from all Blocks (except Axis3 center-on-click interactions). It requires data to be copied from the GPU to CPU which is very expensive compared to bounding box checks, which should be sufficient for blocks. I also added some debug tracking for pick() calls and use those to test that blocks don't rely on them

The second type of changes is driven by message counts as reported by Bonito. Specifically, I ran code like this to check and compare message counts:

using Bonito, WGLMakie
begin
    f = Figure()
    t1 = Textbox(f[1, 1])
    m = Menu(f[2, 1], options = string.(1:100))
    display(f)

    # select TextBox
    events(f).mouseposition[] = (300, 250)
    events(f).mousebutton[] = Makie.MouseButtonEvent(Mouse.left, Mouse.press)
    events(f).mousebutton[] = Makie.MouseButtonEvent(Mouse.left, Mouse.release)

    # emulate text input & track updates
    all_messages, summary_str = Bonito.collect_messages() do
        events(f).unicode_input[] = 't'
        events(f).unicode_input[] = 'e'
        events(f).unicode_input[] = 's'
        events(f).unicode_input[] = 't'
    end
    summary_str
end

Commits with notes like 32 -> 4 refer to reductions in those message counts. Changes made in this context can have heavy overlap with or be made redundant by #4630. For example text input often creates a lot of redundant updates because most text things trigger an update of the glyph collection which then triggers an update of everything that depends on the glyph collection. #4630 is partially meant to deal with that, so there's little point in optimizing it here.
Instead of that most of the message count reductions here are related to not doing unnecessary work.

With respect to #4074 mainly e7c5450 and 55cd8a7 are relevant. These commits remove updates of hidden menu items caused by layouting changes. Before there were 72 messages per letter typed and the total size scaled with the number of menu items. Now there are 39 (just Textbox triggers 30 per letter) and no scaling with the number of Menu items.

TODO:

  • add message count tests
  • check other Blocks for excessive message counts

Type of change

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

Checklist

  • Added an entry in CHANGELOG.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 24, 2025

Benchmark Results

SHA: 25f463c2db9333628584bc94d00ddb9107ad3a16

Warning

These results are subject to substantial noise because GitHub's CI runs on shared machines that are not ideally suited for benchmarking.

GLMakie
CairoMakie
WGLMakie

@ffreyer
Copy link
Collaborator Author

ffreyer commented Feb 25, 2025

After some discussion with Simon we decided to skip the message counting tests for now. #4630 should make it possible to handle them more easily and across backends. So we'll defer them to there instead of wasting time here trying to figure out why these tests don't work here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Work in progress
Development

Successfully merging this pull request may close these issues.

2 participants