Optimize cross tile symbol index - #1
Conversation
| for (const [coordinateId, symbolInstancesAtCoordinate] of coordinateMap.entries()) { | ||
| const x = coordinateId >>> 16; | ||
| const y = coordinateId % (1 << 16); | ||
| const indexes = entry.index.range( |
There was a problem hiding this comment.
Running the range query on large indexes for N symbol instances was the slow path.
The main optimization here is to instead group all the unique coordinates from the N symbol instances (which is typically significantly less than N), and running the range query once per unique coordinate.
Then try and pair as many of the range query entries with a symbol instance as possible.
|
|
||
| for (const [coordinateId, symbolInstancesAtCoordinate] of coordinateMap.entries()) { | ||
| const x = coordinateId >>> 16; | ||
| const y = coordinateId % (1 << 16); |
There was a problem hiding this comment.
If I'm understanding correctly -- it's probably faster to mask this back out coordinateId & 0xFFFF vs modulo.
There was a problem hiding this comment.
Weirdly I tried & 0xFFFF originally and it was slower in profiles. But worth playing around with a few options.
358ed03 to
efaaea5
Compare
|
PR'd against maplibre here: maplibre#6641 |
Running some benchmarks:
Pal: 20x
Pal: 55x
Pal: 111x
Also tested zooming in and out on a map with 20k symbols:
Launch Checklist
CHANGELOG.mdunder the## mainsection.