-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
queryRenderFeatures continued [not ready] #2224
queryRenderFeatures continued [not ready] #2224
Commits on Mar 24, 2016
-
Configuration menu - View commit details
-
Copy full SHA for e34197e - Browse repository at this point
Copy the full SHA e34197eView commit details -
index collision boxes with a grid instead of rtree
The combined running time of placeCollisionFeature and insertCollisionFeature is now 2/3rds of what it used to be. The grid index divids a square into n x n cells. When a bbox is inserted, it is added to the array of every cell it intersects. When querying, look in all the cells that intersect the query box and then compare all the individual bboxes contained in that cell against the query box. This kind of index is faster in this specific case because it's characteristics better match the work we're using it for. Queries can take 1.3x as long (slower) with the grid index. But insertions often take < 0.1x as long with the grid index. Our collision detection code does a lot of insertions so this is a worthwhile tradeoff. The grid index also takes advantage of the fact that label boxes are fairly evenly sized and evenly distributed. The grid index can also be serialized to an ArrayBuffer. The ArrayBuffer version can be queried without deserializing all the individual objects first. This is not currently used.
Configuration menu - View commit details
-
Copy full SHA for b62895a - Browse repository at this point
Copy the full SHA b62895aView commit details -
store CollisionBoxes in an ArrayBuffer
This reduces the long-term memory usage of a tile by ~500KB. Saving memory is significant because it lets us cache more parsed tiles. This also speeds up CollisionFeature creation by about 60%. It's hard to measure, but this probably saves us a bit of gc time. Using an ArrayBuffer to store the data makes it potentially transferrable, which moves us closer to eliminating worker state. --- This also adds StructArray, a pretty fast and convenient way of adding conceptual objects to ArrayBuffers. var BoxArray = createStructArrayType([ { type: 'Int16', name: 'x1' }, { type: 'Int16', name: 'y1' }, { type: 'Int16', name: 'x2' }, { type: 'Int16', name: 'y2' }, { type: 'Float32', name: 'scale' }, ]); var boxes = new BoxArray(); boxes.emplaceBack(-2, -1, 2, 1, 1.23); boxes.emplaceBack(-3, -1, 3, 1, 1.23); var box = boxes.at(0); assert(box.x2 - box.x1 === 4); box._setIndex(1); // avoid creating a new box object assert(box.x2 - box.x1 === 6); How fast is it compared to regular objects? Adding features with emplaceBack is faster. Accessing and setting individual components is a tiny bit slower.
Configuration menu - View commit details
-
Copy full SHA for 11c8bb5 - Browse repository at this point
Copy the full SHA 11c8bb5View commit details -
Configuration menu - View commit details
-
Copy full SHA for 9b4f1b3 - Browse repository at this point
Copy the full SHA 9b4f1b3View commit details -
Configuration menu - View commit details
-
Copy full SHA for 3e45db3 - Browse repository at this point
Copy the full SHA 3e45db3View commit details -
use grid index instead of rtree for querying features
Why? Both indexes have comparable querying performance and Grid is transferrable. Insertion is faster with Grid than rbush but that's not the main benefit. Point queries are really fast for both. Each is sometimes faster than the other. Therre is no clear winner. Large, full-screen bbox queries are 10% slower with Grid than rbush but difference is not significant (0.2% of FeatureTree.query). comparisons were done with mapbox-streets-v6
Configuration menu - View commit details
-
Copy full SHA for 16655f7 - Browse repository at this point
Copy the full SHA 16655f7View commit details -
move queryRenderedFeatures to the main thread
- it's fast - this helps avoid worker postMessage clone costs - this prevents busy workers from delaying the results - this is a step towards lazily constructing GeoJSON and eliminating `includeGeometry`
Configuration menu - View commit details
-
Copy full SHA for 9bd9b0a - Browse repository at this point
Copy the full SHA 9bd9b0aView commit details -
index each line/ring of a geometry separately
This improves performance for large multipolygons and multilines. mapbox-streets-v7 collects features with identical properties and combines into a single giant feature. This saves space and speeds up parsing but it also makes indexing by feature bbox useless.
Configuration menu - View commit details
-
Copy full SHA for 571a8e7 - Browse repository at this point
Copy the full SHA 571a8e7View commit details -
Configuration menu - View commit details
-
Copy full SHA for dd4f2a0 - Browse repository at this point
Copy the full SHA dd4f2a0View commit details -
remove
includeGeometry
and lazily build geojson geometryThe code for converting to geojson is copied from https://github.com/mapbox/vector-tile-js 0f73eb2c417979601be973e046e169c74147ca7
Configuration menu - View commit details
-
Copy full SHA for e72a467 - Browse repository at this point
Copy the full SHA e72a467View commit details -
Configuration menu - View commit details
-
Copy full SHA for 3da7cd4 - Browse repository at this point
Copy the full SHA 3da7cd4View commit details -
move querySourceFeatures to main thread
It's much faster to deserialize straight from pbf than to deserialize and reserialize as GeoJSON. This also lets us lazily load geometries to make it even faster for cases where not all geometries are used. benchmark with buildings in mapbox-streets-v7 old (with stringify added) 85ms new 1.5 ms new with all geometries loaded 15ms benchmark with buildings in mapbox-streets-v6 old 500ms old (with stringify added) 150ms new 3ms new with all geometries loaded 15ms
Configuration menu - View commit details
-
Copy full SHA for 845e9d2 - Browse repository at this point
Copy the full SHA 845e9d2View commit details -
Configuration menu - View commit details
-
Copy full SHA for 0bbd180 - Browse repository at this point
Copy the full SHA 0bbd180View commit details -
Configuration menu - View commit details
-
Copy full SHA for 73a6e57 - Browse repository at this point
Copy the full SHA 73a6e57View commit details -
add async version of queryRenderedFeatures
Despite being potentially parallelized, this often takes longer than the synchronous verion because the features have to be parsed from the pbf twice instead of once. The advantage of the async version is that it spends less time in the main thread which can keep the everything more responsive. It still takes some time to parse all the features from the vector tile into geojson (~15ms for a full screen query in a dense area). Parsing the pbf on the main thread is faster than parsing json. Parsing the pbf on the main thread also lets us lazily load the geometry and avoid implementing the `includeGeometry` option.
Configuration menu - View commit details
-
Copy full SHA for abc7b93 - Browse repository at this point
Copy the full SHA abc7b93View commit details -
Configuration menu - View commit details
-
Copy full SHA for 2b971f5 - Browse repository at this point
Copy the full SHA 2b971f5View commit details -
optimize polygonIntersectsBufferedMultiLine
for when polygon is just a point.
Configuration menu - View commit details
-
Copy full SHA for 8dc1d43 - Browse repository at this point
Copy the full SHA 8dc1d43View commit details -
Configuration menu - View commit details
-
Copy full SHA for 1227aa0 - Browse repository at this point
Copy the full SHA 1227aa0View commit details -
Configuration menu - View commit details
-
Copy full SHA for e89fe1c - Browse repository at this point
Copy the full SHA e89fe1cView commit details -
only create Int32Array for non-empty cells
This significantly reduces memory usage for CollisionTiles that aren't used, or are barely used.
Configuration menu - View commit details
-
Copy full SHA for c84642f - Browse repository at this point
Copy the full SHA c84642fView commit details -
Configuration menu - View commit details
-
Copy full SHA for a92d4e0 - Browse repository at this point
Copy the full SHA a92d4e0View commit details -
Configuration menu - View commit details
-
Copy full SHA for a31b379 - Browse repository at this point
Copy the full SHA a31b379View commit details -
Configuration menu - View commit details
-
Copy full SHA for 14df0f3 - Browse repository at this point
Copy the full SHA 14df0f3View commit details -
Configuration menu - View commit details
-
Copy full SHA for cfdda7b - Browse repository at this point
Copy the full SHA cfdda7bView commit details -
Configuration menu - View commit details
-
Copy full SHA for 5f60ecc - Browse repository at this point
Copy the full SHA 5f60eccView commit details -
Configuration menu - View commit details
-
Copy full SHA for 066462e - Browse repository at this point
Copy the full SHA 066462eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 099ec01 - Browse repository at this point
Copy the full SHA 099ec01View commit details -
fix tests for queryRenderedFeatures
remove all FeatureTree tests. FeatureTree is covered by the query render tests. It's really hard to construct and verify test cases without visual help. Whenever the FeatureTree tests break its hard to tell if its a broken test or a broken implementation. It's way easier to create good query tests.
Configuration menu - View commit details
-
Copy full SHA for 1625f6d - Browse repository at this point
Copy the full SHA 1625f6dView commit details -
Configuration menu - View commit details
-
Copy full SHA for d76b23f - Browse repository at this point
Copy the full SHA d76b23fView commit details -
Configuration menu - View commit details
-
Copy full SHA for 0fdd868 - Browse repository at this point
Copy the full SHA 0fdd868View commit details -
Configuration menu - View commit details
-
Copy full SHA for f8aeecf - Browse repository at this point
Copy the full SHA f8aeecfView commit details -
Configuration menu - View commit details
-
Copy full SHA for 1594938 - Browse repository at this point
Copy the full SHA 1594938View commit details -
Configuration menu - View commit details
-
Copy full SHA for e56a49e - Browse repository at this point
Copy the full SHA e56a49eView commit details -
rename layers property from
layer
tolayers
and accept only an array of strings. fix #2230
Configuration menu - View commit details
-
Copy full SHA for dfb96c8 - Browse repository at this point
Copy the full SHA dfb96c8View commit details -
Configuration menu - View commit details
-
Copy full SHA for 3164a64 - Browse repository at this point
Copy the full SHA 3164a64View commit details -
Configuration menu - View commit details
-
Copy full SHA for b6fe1c0 - Browse repository at this point
Copy the full SHA b6fe1c0View commit details -
Configuration menu - View commit details
-
Copy full SHA for 64a77b9 - Browse repository at this point
Copy the full SHA 64a77b9View commit details -
Configuration menu - View commit details
-
Copy full SHA for 41c4b70 - Browse repository at this point
Copy the full SHA 41c4b70View commit details -
Configuration menu - View commit details
-
Copy full SHA for 20cc526 - Browse repository at this point
Copy the full SHA 20cc526View commit details -
Configuration menu - View commit details
-
Copy full SHA for 956a6e9 - Browse repository at this point
Copy the full SHA 956a6e9View commit details -
Configuration menu - View commit details
-
Copy full SHA for d886a2e - Browse repository at this point
Copy the full SHA d886a2eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 25df374 - Browse repository at this point
Copy the full SHA 25df374View commit details -
It's faster, but not fast enough to be worth it.
1Configuration menu - View commit details
-
Copy full SHA for afa28ea - Browse repository at this point
Copy the full SHA afa28eaView commit details -
Configuration menu - View commit details
-
Copy full SHA for b1517ef - Browse repository at this point
Copy the full SHA b1517efView commit details -
Configuration menu - View commit details
-
Copy full SHA for f96e807 - Browse repository at this point
Copy the full SHA f96e807View commit details -
remove queryRenderedFeaturesAsync
let's try to get by with just queryRenderedFeatures
Configuration menu - View commit details
-
Copy full SHA for e79a7ec - Browse repository at this point
Copy the full SHA e79a7ecView commit details -
Configuration menu - View commit details
-
Copy full SHA for 7531605 - Browse repository at this point
Copy the full SHA 7531605View commit details -
rename FeatureTree to FeatureIndex
and split intersection tests into a separate file
Configuration menu - View commit details
-
Copy full SHA for 056fbc0 - Browse repository at this point
Copy the full SHA 056fbc0View commit details