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

Tracker: optimisations #165

Open
2 of 4 tasks
dhardy opened this issue Feb 23, 2021 · 3 comments
Open
2 of 4 tasks

Tracker: optimisations #165

dhardy opened this issue Feb 23, 2021 · 3 comments
Labels
low priority Not a near-term goal / not easily achievable optimisation

Comments

@dhardy
Copy link
Collaborator

dhardy commented Feb 23, 2021

A tracker for notable optimisations (generally low priority so long as the UI appears sufficiently fast).

@dhardy
Copy link
Collaborator Author

dhardy commented Feb 24, 2021

Avoid unnecessary redraws when hover target changes

This is done

The Manager::set_hover method (src/event/manager.rs:238) requests a redraw whenever the mouse moves over a different widget, since the "hover status" of a widget may affect how it is drawn (e.g. to highlight a button). Many widgets, however, are not affected by this, thus many of these redraws are unnecessary; unfortunately the Manager doesn't know which widgets have hover highlighting and currently there is no way to communicate this.

Possible ideas:

  • Send messages to widgets when mouse-hover status is set/lost, which can request redraws if necessary — this is significant extra event processing but still less work than redrawing
  • Extra method in WidgetConfig
  • Work towards partial redraws?

@dhardy dhardy added the low priority Not a near-term goal / not easily achievable label Jun 15, 2021
@dhardy
Copy link
Collaborator Author

dhardy commented Mar 3, 2022

Reduce size of data types

  • PressSource is surprisingly large: the value of Touch is 64-bits since on OSX it is a pointer (on all other platforms it is a 32-bit integer); adding the tag makes this a 16-byte type. If the tag could be moved elsewhere (into Event or within the value of Touch) then this and Event would be smaller. Hint: pointers are aligned, thus the smallest 2-3 bits must be zero; unfortunately this requires unsafe platform-specific code.
Current sizes
#[cfg(test)]
#[test]
fn type_sizes() {
    use std::mem::size_of;

    assert_eq!(size_of::<Event>(), 48);
    assert_eq!(size_of::<PressSource>(), 16);
}

@dhardy
Copy link
Collaborator Author

dhardy commented Jul 16, 2022

#335 removed usage of the stack_dst crate which was used to avoid some heap allocations. No performance issues were noted as a result and this removed an unsafe and unstable dependency. Eventually Rust may directly support returning unsized trait-impl objects on the stack, but until then it doesn't appear to be a real issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
low priority Not a near-term goal / not easily achievable optimisation
Projects
None yet
Development

No branches or pull requests

1 participant