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

[WIP] Fetch and decode buckets in webworker #3068

Closed

Conversation

philippotto
Copy link
Member

Even though, async fetching of data is supposed to not block the main thread, I noticed performance improvements on my setup (speed up factors reaching from 1.3 to above 2.0).

The code in this PR is hacked together as a prototype. If we decide to go with webworkers, we should think about how we want to structure the code so that code duplication is avoided.

My setup was:

  • load a dataset with segmentation so that zoom step 0 is used (shortly before zoom step 1 to maximize the bucket count)
  • set segmentation opacity to zero and refresh the page
  • wait until after loading is completed
  • [optional: set window.useWebWorker = true to test with web worker]
  • start the perf measurement
  • change seg opacity from 0 to 50 (via keyboard; not slider)
  • after all segmentation buckets are loaded, use chrome's screenshot timeline to see the exact interval in which buckets were loaded (i.e., the first screenshot showing 50, and the first screenshot showing complete data)

The overall time did reduce drastically for me, when the webworker was active (JS execution time itself didn't change very much). Also, the idle time was higher (above 100ms instead of 1 ms).

We should try to reproduce these findings on at least one other system.

In general, using a webworker introduces more complexity (e.g., due to the code isolation). Also it's not clear to me why this perf improvement exists. It would make sense, if the perf speed up was due to the decoding of 4 bit data, but segmentation data is never encoded in 4-bit...

URL of deployed dev instance (used for testing):

Steps to test:

  • abc

Issues:


@philippotto philippotto self-assigned this Aug 17, 2018
@philippotto philippotto changed the base branch from master to dont-load-invisible-segmentation August 17, 2018 12:24
@daniel-wer
Copy link
Member

Very cool :)

I'll add my measured times (measured on https://bucketwebworker.webknossos.xyz). In contrast to you, I measured the time from changing the segmentation opacity to 50 until ALL buckets were loaded (as it was not easily recognizable for me when the viewports were fully loaded from the screenshots, so I used the network display):

Without webworker: 8.18s (100ms Idle)
With webworker: 6.38s (2047ms Idle)

Very impressive, especially the huge difference in idle time!
I also don't know where exactly this speedup is coming from, the only thing I noticed is that without the webworker, Chrome spends more than half of the execution time doing "Other" stuff (not sure what this is). With a webworker this time spent doing "Other" stuff is decreased considerably.

@philippotto
Copy link
Member Author

Closing this in favor of #3162, which implements the webworker approach properly.

@philippotto philippotto closed this Sep 6, 2018
@normanrz normanrz deleted the bucket-webworker branch February 20, 2019 16:35
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.

2 participants