Scene#drillPick performance scales poorly
- Dominant language
- JavaScript
- Stars
- 15.7k
- Forks
- 3.9k
- Avg merge
- 4d 6h
- Merged PRs (30d)
- 34
Description
[Sandcastle example](https://sandcastle.cesium.com/#c=bVTvb9owEP1XTqgfnC0zlPXD1ALaBkyb1m7VQNsXpGHig5o5dhQ7tAzlf9/lByR0/RTn7t27d8+XRNY4DzuFj5jCEAw+whidymL+s4yxRScq38fWeKEMpotOCIeFAXARGryzEq+PJbNjhM/G02/T/iQscF7FqKnyGtZCOyxjwqhYeGVNE8yDm4VZmKgUdKia/lJygz6sWuWkrxLaAiarc9X3ynzMlJakvOBb2xSYRg+KYL0begygXzxfDy+DaowTZFtBtjVk20Cg7svReOUVOi6kZHUKILFOVbPUIsYi9XQS5i1fpzae4CZFdKzHL+EVqBCqwzYIjwwrpfXKilRew4kVgCzakGvJqmSZ45Nny4uDysOLwzZfhqduVtuU/5hOQrh613Dm9an0lR7kcGFbPcla7+eWPRurvoGW9dxFJN3MEhHhdEe4z8JITSUO/ReTZP5DVEzO2OFoQh7AcFRNUdyQ1ci13bDlvYr+KLOBFfpHYoRe2KMtkHBxquRP3Nv7FCPlCsqroBj0lNw/Ty6ruao1iJUkWeercLqFPmtadPshNJzdfpvEeaqoOSbCIws4WTCn9WVtWIoFqFxJLlO6uWI0VikIITMS17TtstXnqd2zoTrzBgsriJprNBv/kEOijANlKHon/ANdmLUpe0kavKmUB3nseOlKHjZf5Pn1zfcJ8tvpp/nv8e2X8dfgphN2Bs7vNY6Oe/NexYklH7JUM867HuNEU0fXXWWk0vPIlXsy6LbLBlLtQMnhC38LiLRwjjLrTOuZ+ouLzmjQJfx/pdoKSSvyfYepFvsC9nA5uq2CnPNBl15frvTW6pWgZqcpmpyinwAlCh6Ux/I2zT8): Open, then click anywhere on the map to select between the top-left corner of the canvas and the clicked location. The console tab will log the number of pins included (to make sure the correct point was used) and the time in milliseconds spent in the call to `drillPick`.
Browser: Chrome stable, latest
Operating System: Win10 latest
----
There are 2 related problems here.
First, try zooming and scrolling such that you have a few pins (say 3x3 to 5x5 square) in the top left corner (say 200x200 px or so). On my machine I can pick 9 pins in a 150x150px region in 70ms. Now, without moving the camera, click close to the bottom right corner. On my machine that was a 900x600px region with 228 pins -- and the call locked the main thread for a full 8 seconds (!). By contrast a pick with the same region (900x600px) only takes 50ms if there are no pins in it.
Second, zoom way out so that most of the pins are huddled in the top-left corner. I'm able to get all 400 pins in a 150x150px region, and it "only" takes 1400ms -- a lot longer than 9 pins in the same region, but a lot shorter than the same number of pins in a much larger region.
So, it seems that drillPick runtime scales by both the size of the region being considered, and the number of entities in the region, but neither relationship is linear. I'm hoping somebody has some bright ideas to improve performance, but I'd also welcome suggestions for going about this another way. I've seen suggestions to derive a `Rectangle` representing the selected region, then check the Entity position using `contains`, but that scales poorly compared to `drillPick` if most of your Entities are offscreen, and also doesn't handle the case of Entities that don't need a `position` e.g. because they just use non-relative Graphics like `polygon` / `polyLine` / etc.
Contributor guide
Research direction
Start with the linked Sandcastle example and reproduce the measurements in Chrome, varying the picked region and pin count. Trace the Scene#drillPick path to identify where these costs arise; the issue does not name a source file, test, or agreed performance target, so those would need to be established before defining done.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- computer-graphics, performance
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100