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

Proposal: reuse the same EffectiveViewportChangedEventArgs object #9256

Open
FrayxRulez opened this issue Jan 18, 2024 · 2 comments
Open

Proposal: reuse the same EffectiveViewportChangedEventArgs object #9256

FrayxRulez opened this issue Jan 18, 2024 · 2 comments
Labels
area-Performance feature proposal New feature proposal team-CompInput Issue for IXP (Composition, Input) team

Comments

@FrayxRulez
Copy link

Currently, every time EffectiveViewportChanged is fired, a new EffectiveViewportChangedEventArgs is created.
While this is probably fine in C++, it causes a huge memory traffic in C# and consequently a large amount of garbage collections.
I see from the source code that quite a few events reuse the same args over and over for performance reasons (ListView.ContainerContentChanging to mention one), and I guess it would make sense to do it here too, as EffectiveViewportChanged callbacks tend to be a hot path (tracking visible elements on screen in scrollable areas and such).

@FrayxRulez FrayxRulez added the feature proposal New feature proposal label Jan 18, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage Issue needs to be triaged by the area owners label Jan 18, 2024
@bpulliam bpulliam added area-Performance and removed needs-triage Issue needs to be triaged by the area owners labels Jan 18, 2024
@codendone
Copy link
Contributor

Note: We frequently can't reuse event args because event handlers may be asynchronous and holding on to the args. Some tricks could potentially be done, like using a pool and watching for when the event args are no longer in use.

@FrayxRulez
Copy link
Author

Judging from CLayoutManager::RaiseEffectiveViewportChangedEvents it seems possible to at least recycle the same args per queue batch (Raise is being invoked with fRaiseSync TRUE)

@bpulliam bpulliam added the team-CompInput Issue for IXP (Composition, Input) team label May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Performance feature proposal New feature proposal team-CompInput Issue for IXP (Composition, Input) team
Projects
None yet
Development

No branches or pull requests

3 participants