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

Improve performance of content size calculation in List #4835

Merged
merged 2 commits into from
May 18, 2024

Conversation

dweymouth
Copy link
Contributor

@dweymouth dweymouth commented May 9, 2024

Description:

Makes calculating the content size in List O(n) in the number of custom-height items rather than the number of total items. Unsurprisingly, a huge performance improvement for long lists with only a few custom item heights (as is a common use case).

Fixes #3427 (for list)

Checklist:

  • Tests included. <- already covered by existing tests
  • Lint and formatter run with no errors.
  • Tests all pass.

Benchmark (before):

goos: darwin goarch: arm64 pkg: fyne.io/fyne/v2/widget

BenchmarkContentMinSize-8 198 6114649 ns/op 0 B/op 0 allocs/op PASS ok fyne.io/fyne/v2/widget 2.062s

Benchmark (after):

goos: darwin goarch: arm64 pkg: fyne.io/fyne/v2/widget

BenchmarkContentMinSize-8 19891040 51.04 ns/op 0 B/op 0 allocs/op PASS ok fyne.io/fyne/v2/widget 1.565s

@dweymouth dweymouth requested a review from Jacalz May 9, 2024 15:20
@coveralls
Copy link

coveralls commented May 9, 2024

Coverage Status

coverage: 65.069% (-0.001%) from 65.07%
when pulling b8b6b5c on dweymouth:list-size-optimization
into 54154f9 on fyne-io:develop.

@dweymouth dweymouth added this to the "Elgin" release, early 2024 milestone May 11, 2024
Copy link
Member

@Jacalz Jacalz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to #4841, I think we should add more benchmarks to List so these optimizations are easier to reason about. Apart from that, the change seems like a nice one :)

@dweymouth dweymouth requested a review from Jacalz May 18, 2024 15:58
Copy link
Member

@Jacalz Jacalz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. That makes it easier to reason about

@dweymouth dweymouth merged commit 4fa888a into fyne-io:develop May 18, 2024
12 checks passed
@dweymouth dweymouth deleted the list-size-optimization branch May 18, 2024 16:51
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.

3 participants