Description
Currently, we trust our users to have optimised the tiles and styles themselves.
Thing is, I don't think they do that optimally and think that we could do better.
This is definitively dependent on
To get performance benchmarks, likely also need
These optimiations only work if the style is static => a development mode is not something that would work with this model
There are optimisations, which we can do
- [ALWAYS]
- [SOMETIMES] (only for static data)
- [NEVER] (would impact rendering)
Optimising the styles
One potential optimization I thought of is "query-optimizing" styles, similar to how databases optimize queries.
Here are some possible optimizations that might be achievable with a reasonable effort:
- [ALWAYS] remove impossible or hidden sources
- [SOMETIMES] optimise the order of filter-selections in for example "any", "all", "match", "case" by selectivity
- [SOMETIMES] if certain that a predicate can never/ will always happen => replace with the literal
- [SOMETIMES] (unsure if benefitial) add ´{min,max}_zoom´ tags based on the actual data, filters and impossible styling conditions (think: oppacity=0), not just the part we export to tilejson
Opimising the tiles
This is likely a lot harder and much more of a risk.
Here is mapbox docs on a similar feature.
After discussion on slack, this blog post and this github repo came up doing the same thing
- [ALWAYS] make sure that martin only encodes the exact data that a style would actually look at.
- => "pre-filter" before going over the network
- [SOMETIMES] cache the filtered output
optimised sprites
Some styles may permit to statically know which sprites are going to be used.
For others, we might need to do a "full table scan" to gather this statistic.
Optimised fonts
nothing that I can think of.
Maybe pre-warming a cache, but nothing major.
Discussion
Now to the fun part:
- How effective would these be?
- Would there be other optimisations are safely possible to do?
- What optimisations do maplibre-{native,gl} already do in this area?
- Are there tile servers/other projects (which I missed) that tired this in the past?