Skip to content
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

Perform bucket picking in web workers and other performance optimizations #3902

Merged
merged 18 commits into from
Mar 21, 2019

Conversation

philippotto
Copy link
Member

@philippotto philippotto commented Mar 18, 2019

TLDR:

  • Bucket picking is done in a dedicated webworker (bucket picking for selecting the correct magnification is still done synchronously, since the complexity wouldn't be worth it). The look-up from the bucket positions to the actual buckets is still done in the main thread, since we don't have easy access to the DataCube in the webworker.
  • There is only one webworker which deals with all bucket picking tasks. I implemented a LatestTaskExecutor class which is used in combination with the bucket picking to ensure that bucket picking tasks cannot queue up (only the newest one is relevant). I tested this by slowing each bucket picking artificially done to take 200 ms.
  • The results of the latest bucket picking result is shared across all data layers.
  • I also ensured that bucket picking is not initiated for segmentation layers in arbitrary mode, even though this perf gain is bit overshadowed by the previous optimization.

A word abut the look up buffer for the TextureBucketManager:
The creation of that buffer is quite complex now and frankly a bit of a shit show. Since the bucket picking is done asynchronously, there are frames in which the TextureBucketManager doesn't know which buckets are supposed to be on the GPU. In that case, all available buckets should be put into the look up buffer, so that the shader can access them. I wrote a comment into the texture bucket which hopefully explains this. If it's unclear, hit me up. In the long-term I think we should do the addressing with cuckoo hashing or something similar.

URL of deployed dev instance (used for testing):

  • https://___.webknossos.xyz

Steps to test:

  • use ortho and the two flight modes
  • test progressive vs. best quality loading strategy

Issues:


@@ -67,7 +67,7 @@ export default function determineBucketsForFlight(
const cameraDirection = V3.sub(centerPosition, cameraPosition);
V3.scale(cameraDirection, 1 / Math.abs(V3.length(cameraDirection)), cameraDirection);

const iterStep = 10;
const iterStep = 8;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also tweaked the values for the arbitrary mode pickers a bit, since they are not that perf criticial anymore.

Copy link
Member

@daniel-wer daniel-wer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice! I'm excited to measure performance on a deployed version :)
I like the clean design and tests for the latest_task_executor.js.

I do agree that the _refreshLookUpBuffer method is fairly complex and we should think about ways to improve that, but one has to note, that zooming in and out is super-smooth now, no flickering! 👍

@philippotto philippotto merged commit 8ae4dab into master Mar 21, 2019
hotzenklotz added a commit that referenced this pull request Mar 25, 2019
…ture-highlight

* 'master' of github.com:scalableminds/webknossos:
  Hide unreported datasets (#3883)
  Update puppeteer and refresh screenshots (#3914)
  only show team names of own organization (#3928)
  Enable merger mode in skeleton and hybrid tracings (#3619)
  allow uploading nml for public dataset of different orga (#3929)
  Always make wheel listeners not passive to allow preventDefault (#3939)
  Enhance tree search functionallity (#3878)
  add webknossos-connect to setup (#3913)
  Update README.md (#3923)
  Add shortcut to maximize golden layout panes (#3927)
  Perform bucket picking in web workers and other performance optimizations (#3902)
  remove alt text for abstract brain loading image (#3930)
  updated documentation front page (#3917)
@normanrz normanrz deleted the webworkerbucketpicking branch August 12, 2019 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Perform bucket picking in webworker
2 participants