-
-
Notifications
You must be signed in to change notification settings - Fork 977
Speed up GeoJSONSource#updateData #6562
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
This was posted by @wayofthefuture, not me.
In eb69274 I moved the calculation of This does not make the code measurably faster in any benchmark I have run. It does make the code harder to read and harder to test.
There is no "parsed geometry data" on the worker that we can reuse. For the purposes of this feature, the worker has exactly the same data as the main thread. |
|
Oh well, now I'm just confused. In a perfect world geojson source would always control source but it doesn't. That's our reality. Source cache does the controlling. reloadTile, loadTile, addTile lives in source cache. The decision to reload is currently in source cache, splitting that decision and creating types to transport a function is confusing. The hodgepodge that is source cache is a problem for another day. I'm not a fan of shouldReloadTile in the current form... and I'm definitely not a fan of shouldReloadTileOptions so that a function can be passed... respectfully... my opinion. Sorry |
I tend to agree, sorry for pushing in the wrong direction, I think this can be reverted if it's not a big ask. |
|
I meant the last change with the worker, the rest is ok. |
This reverts commit eb69274.
Reverted in cea0e71 |
|
Added a few last final comments, and I'll merge this afterwards. |
|
@lucaswoj I'm not sure if this PR is the cause, but see the behavior difference between 5.10.0 and 5.11.0 where this commit was merged. Notice how the extruded boxes are sticking around and not being removed... Before: before.movAfter: after.movAll you have to do is change the version number in this codepen to reproduce: |
* Add geojson diff benchmark * Update geojson_diff.ts * Update geojson_diff.ts * WIP * WIP * WIP * WIP * WIP * WIP * Self code reivew * Self code reivew * Self code reivew * WIP * WIP * Update geojson_diff.ts * Refactor * Update min.test.ts * Fix CI * WIP * Add unit tests * Self code reivew * Add tests for LngLatBounds#intersects * WIP * Update geojson_source.test.ts * Add more tests * Fix eslint * Add large diff bail * Update display-a-map.html * Update geojson_diff.ts * Update CHANGELOG.md * Self PR review bump CI * Memoize some operations on _getShoudReloadTile * Add failing dateline wrap test * WIP * Update lng_lat_bounds.ts * Update geojson_source.ts * Self PR review * Update lng_lat_bounds.ts * PR review * Self PR review * Fix tests * Self code review * Remove 1000 feature heuristic * Update source_cache.ts * Move tileIdToLngLatBounds to standalone util * Remove 'extent' parameter from tileIdToLngLatBounds * Rename "shared" to "shouldReloadTile" * Remove "else if" statements * Update geojson_source.test.ts * Refactor to use MapSourceDataEvent#shouldReloadTileOptions * Fix CI * Self code review * Self code review * Move getGeoJSONBounds to separate util file * Fix error * Calculate 'nextBounds' on the worker * Revert "Calculate 'nextBounds' on the worker" This reverts commit eb69274. * Restore bug fix from eb69274 * Fix typo * Add doc link * Don't use to hide GeoJSONSourceShouldReloadTileOptions * Update display-a-map.html
This PR speeds up
GeoJSONSource#updateDatawhen called with small diffs. Now we only reload tiles affected by the diff, rather than reloading all tiles. This significantly improves performance when making small changes to large GeoJSON datasets.Performance Impact
Implementation
When
updateDatais called with a diff, the source now determines which tiles need reloading by:Additional Changes
LngLatBounds.intersects()method for bounds overlap testingCanonicalTileID.toLngLatBounds()to convert tile coordinates to geographic boundsupdateDataperformanceRelated to #4364
Launch Checklist
CHANGELOG.mdunder the## mainsection.