Skip to content

vector: Some optimizations for the expression code

My development branch of the map style at https://gitlab.gnome.org/jwestman/map-style currently has 1266 layers. There are some things we could implement in libshumate to let us bring that down a bit, but without changes to the MapLibre format, if we want roads to be layered properly, we're going to have at least hundreds of sparse style layers. According to sysprof, it currently takes about as much time to evaluate all those layers' filters as it does to paint the graphics, so I've implemented a couple optimizations:

  • Remove the type check in shumate_vector_expression_eval(). The function isn't public API, and it's a hot path, so removing it is a small but measurable performance improvement.
  • (Much more significant) Implement fast paths for common expression combinations, such as checking whether the value of a certain tag is in a certain set. The combinations that are optimized cover most of what map styles use in practice.

Overall, on the new map style, these changes bring a 2-3x speedup in filter evaluation.

If we still need filter evaluation to be faster, I might look into indexing the features with bitmaps.

Merge request reports