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

perf: reduce tile management overhead #1709

Merged
merged 4 commits into from
Oct 30, 2023

Conversation

ignatz
Copy link
Contributor

@ignatz ignatz commented Oct 27, 2023

Consumed some single digit percent frame time for me. Improved contributions:

  • Don't compute hash of hashes.
  • Cheap custom hash.
  • Avoid string interpolation.

Also as a drive-by get rid of the TileCoordinates extends Point + zoom coordinate in favor of more consistent composition.

Copy link
Member

@JaffaKetchup JaffaKetchup left a comment

Choose a reason for hiding this comment

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

I'm a little unsure of some of the changes made. They are very breaking.

lib/src/layer/tile_layer/tile_coordinates.dart Outdated Show resolved Hide resolved
lib/src/layer/tile_layer/tile_coordinates.dart Outdated Show resolved Hide resolved
@ignatz
Copy link
Contributor Author

ignatz commented Oct 29, 2023 via email

@JaffaKetchup
Copy link
Member

Yep, TileCoordinates is public and commonly used by plugins.

@JaffaKetchup JaffaKetchup added this to In Progress in Priority-ish Todo List Oct 29, 2023
Took some single digit percent frame time on my system.

Contributions:

 * Don't compute hash of hashes.
 * Use hash as key and avoid string interpolation.
 * Use a cheap hash designed for x,y,z

Also as a drive-by get rid of the TileCoordinates extends Point + zoom
coordinate in favor of more consistent composition.
@ignatz
Copy link
Contributor Author

ignatz commented Oct 30, 2023

Yep, TileCoordinates is public and commonly used by plugins.

Or is it moistly flutter_map_tile_caching? ;)

I hadn't looked at it this way. From that point of view even reimplemting the same method set would be breaking since TileCoordinates can no longer be referenced as Point :/

I reverted that part of the change. It's not the most critical part anyways. From an aesthetics point of view, I'm certainly not convinced that TileCoordinates is a Point but hey 🤷

@JaffaKetchup
Copy link
Member

Or is it moistly flutter_map_tile_caching? ;)

No no, it's used by many plugins! fmtc_plus_sharing for example. But seriously, this has widespread use - basically any plugin that touches TileProvider or any tile related logic will use it at some point.

I hadn't looked at it this way. From that point of view even reimplementing the same method set would be breaking since TileCoordinates can no longer be referenced as Point :/

Indeed, I had realised that. But there's a breaking change with a year's worth of work of migration to do, and one where most people need to do barely anything. Maybe we should be using x.x.x.x for versioning? 🤔

@JaffaKetchup JaffaKetchup changed the title Reduce the tile management overhead. perf: reduce tile management overhead Oct 30, 2023
Copy link
Member

@JaffaKetchup JaffaKetchup left a comment

Choose a reason for hiding this comment

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

LGTM, many thanks!

@JaffaKetchup JaffaKetchup merged commit b941fd7 into fleaflet:master Oct 30, 2023
6 checks passed
Priority-ish Todo List automation moved this from In Progress to Done Oct 30, 2023
@ignatz
Copy link
Contributor Author

ignatz commented Oct 30, 2023

No no, it's used by many plugins!

That's what they all say :). I'm just pulling your leg.

Thanks for the review. FTR, after our conversation and my little benchmark my old resentment towards math.Point rekindled. I moved my own fork of polylabel to a custom PointDouble which saved almost 20% cycles. Arguably polylabel is more pure number crunching but still, that was way more than I had expected. Maybe something worth thinking about for the future.

@josxha josxha added this to the v7.0 milestone Dec 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

4 participants