-
Notifications
You must be signed in to change notification settings - Fork 0
Optimize cross tile symbol index #1
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
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.