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

Optimize Android implementations #115

Merged
merged 2 commits into from
Jan 30, 2024
Merged

Optimize Android implementations #115

merged 2 commits into from
Jan 30, 2024

Conversation

chrisbanes
Copy link
Owner

@chrisbanes chrisbanes commented Jan 30, 2024

There's a lot of optimizations in this PR, which all add up. Most of it is just boring stuff:

  • Stop creating Path instances every time. They're fairly expensive so creating new ones each time is wasteful. Fixed by adding a Pool allowing acquiring/release of instances. We now basically only ever keep areas.size + 1 paths in memory. Previously we'd create them each time an update which happened (so basically every layout 😬)
  • Stop creating RenderNode instances every time. Hopefully you get the idea from above, same story. We now mutate our internal Effect instances (which hold the RenderNodes), rather than creating a new one every layout.
  • Only invalidate drawing when required. Related to ☝️. As we now keep the same 'effect' instance, we can now keep track of what has changed in between 'updates', and therefore only invalidate when needed.
  • Defer work to draw. Our update call can be called a lot (triggered by state updates), so we don't want to do update work every time it is called. Instead, we now set dirty flags and wait for the next draw call to lazily defer the work.

As I said, none of this is ground breaking stuff. However, this the kind of stuff which Modifier.Node allows us to do since we're no longer in declarative land.

@chrisbanes chrisbanes marked this pull request as ready for review January 30, 2024 18:06
@chrisbanes chrisbanes merged commit ada2726 into main Jan 30, 2024
2 checks passed
@chrisbanes chrisbanes deleted the cb/path-reuse branch January 30, 2024 19:29
ZacSweers referenced this pull request in ZacSweers/CatchUp Feb 5, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [dev.chrisbanes.haze:haze](https://togithub.com/chrisbanes/haze) |
`0.4.5` -> `0.5.0` |
[![age](https://developer.mend.io/api/mc/badges/age/maven/dev.chrisbanes.haze:haze/0.5.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/maven/dev.chrisbanes.haze:haze/0.5.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/maven/dev.chrisbanes.haze:haze/0.4.5/0.5.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/maven/dev.chrisbanes.haze:haze/0.4.5/0.5.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>chrisbanes/haze (dev.chrisbanes.haze:haze)</summary>

### [`v0.5.0`](https://togithub.com/chrisbanes/haze/releases/tag/0.5.0)

[Compare
Source](https://togithub.com/chrisbanes/haze/compare/0.4.5...0.5.0)

#### Highlights

🏃 Optimizations and performance increases (see
[here](https://chrisbanes.github.io/haze/performance/))
🌫️ New Materials library (see
[here](https://chrisbanes.github.io/haze/materials/))
🆕 Tidied up styling API
✨ Updated to Compose Multiplatform 1.6.0-beta01 (and Jetpack Compose
1.6.0)
🔁 Merged haze and haze-jetpack-compose
📜 (Android) New baseline profiles bundled in library. Thanks to
[@&#8203;simonlebras](https://togithub.com/simonlebras) for this.

#### What's Changed

- Baseline profile by
[@&#8203;simonlebras](https://togithub.com/simonlebras) in
[https://github.com/chrisbanes/haze/pull/93](https://togithub.com/chrisbanes/haze/pull/93)
- Baseline Profile tweaks by
[@&#8203;chrisbanes](https://togithub.com/chrisbanes) in
[https://github.com/chrisbanes/haze/pull/95](https://togithub.com/chrisbanes/haze/pull/95)
- Fix Small Typo in Docs by
[@&#8203;jorgedotcom](https://togithub.com/jorgedotcom) in
[https://github.com/chrisbanes/haze/pull/100](https://togithub.com/chrisbanes/haze/pull/100)
- Update dependency androidx.compose.ui:ui-test-manifest to v1.6.0 by
[@&#8203;renovate](https://togithub.com/renovate) in
[https://github.com/chrisbanes/haze/pull/105](https://togithub.com/chrisbanes/haze/pull/105)
- Update androidx.benchmark to v1.2.3 by
[@&#8203;renovate](https://togithub.com/renovate) in
[https://github.com/chrisbanes/haze/pull/103](https://togithub.com/chrisbanes/haze/pull/103)
- Update agp to v8.2.2 by
[@&#8203;renovate](https://togithub.com/renovate) in
[https://github.com/chrisbanes/haze/pull/102](https://togithub.com/chrisbanes/haze/pull/102)
- Update dependency androidx.compose.ui:ui to v1.6.0 - autoclosed by
[@&#8203;renovate](https://togithub.com/renovate) in
[https://github.com/chrisbanes/haze/pull/104](https://togithub.com/chrisbanes/haze/pull/104)
- Update spotless to v6.25.0 by
[@&#8203;renovate](https://togithub.com/renovate) in
[https://github.com/chrisbanes/haze/pull/96](https://togithub.com/chrisbanes/haze/pull/96)
- Merge :haze and :haze-jetpack-compose by
[@&#8203;chrisbanes](https://togithub.com/chrisbanes) in
[https://github.com/chrisbanes/haze/pull/106](https://togithub.com/chrisbanes/haze/pull/106)
- Update plugin com.gradle.enterprise to v3.16.2 by
[@&#8203;renovate](https://togithub.com/renovate) in
[https://github.com/chrisbanes/haze/pull/107](https://togithub.com/chrisbanes/haze/pull/107)
- Update roborazzi to v1.9.0 by
[@&#8203;renovate](https://togithub.com/renovate) in
[https://github.com/chrisbanes/haze/pull/108](https://togithub.com/chrisbanes/haze/pull/108)
- Add HazeStyle class by
[@&#8203;chrisbanes](https://togithub.com/chrisbanes) in
[https://github.com/chrisbanes/haze/pull/110](https://togithub.com/chrisbanes/haze/pull/110)
- Add Haze Materials by
[@&#8203;chrisbanes](https://togithub.com/chrisbanes) in
[https://github.com/chrisbanes/haze/pull/111](https://togithub.com/chrisbanes/haze/pull/111)
- Lots of small fixes by
[@&#8203;chrisbanes](https://togithub.com/chrisbanes) in
[https://github.com/chrisbanes/haze/pull/113](https://togithub.com/chrisbanes/haze/pull/113)
- Optimize Android implementations by
[@&#8203;chrisbanes](https://togithub.com/chrisbanes) in
[https://github.com/chrisbanes/haze/pull/115](https://togithub.com/chrisbanes/haze/pull/115)
- Add macrobenchmark tests by
[@&#8203;chrisbanes](https://togithub.com/chrisbanes) in
[https://github.com/chrisbanes/haze/pull/116](https://togithub.com/chrisbanes/haze/pull/116)

#### New Contributors

- [@&#8203;simonlebras](https://togithub.com/simonlebras) made their
first contribution in
[https://github.com/chrisbanes/haze/pull/93](https://togithub.com/chrisbanes/haze/pull/93)
- [@&#8203;jorgedotcom](https://togithub.com/jorgedotcom) made their
first contribution in
[https://github.com/chrisbanes/haze/pull/100](https://togithub.com/chrisbanes/haze/pull/100)

**Full Changelog**:
chrisbanes/haze@0.4.5...0.5.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/ZacSweers/CatchUp).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4xNTMuMiIsInVwZGF0ZWRJblZlciI6IjM3LjE3MC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Zac Sweers <pandanomic@gmail.com>
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.

1 participant