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

Speed up mapping creation/activation #4103

Merged
merged 5 commits into from
May 21, 2019
Merged

Conversation

daniel-wer
Copy link
Member

@daniel-wer daniel-wer commented May 21, 2019

This PR speeds up mapping creation/activation of large mappings substantially (~5-6x faster). Key optimizations are:

  • avoid resizing of ArrayBuffers by allocating a buffer padded to the correct size right at the start
  • avoid calling Object.keys (and _.size(...) for that matter), as it is really slow for large objects, by keeping track of the keys ourselves

Example: Activating the astrocyte-full mapping went from taking 41.1s overall to taking 8.7s overall for me. The time to create the texture went from taking 23.3s to taking 3.8s.

I added a screenshot test for mappings while I was at it :)

URL of deployed dev instance (used for testing):

Steps to test:

  • Open a tracing and use the mapping UI to activate a mapping. Everything should work and it should be noticeably faster than on master.
  • Use the api to activate a mapping: webknossos.apiReady().then(async api => api.data.setMapping("segmentation", { <visible_id>: 0}))

Copy link
Member

@philippotto philippotto left a comment

Choose a reason for hiding this comment

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

awesome

Excellent PR! Very cool that you found the culprit plus a nice workaround for it 👍 And the additional screenshot test is the cherry on top 🍒

await page.waitFor(500);
inputCatchers = await page.$(".inputcatcher");
Copy link
Member

@philippotto philippotto May 21, 2019

Choose a reason for hiding this comment

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

Nice catch / improvement!

@daniel-wer daniel-wer merged commit 586a7f4 into master May 21, 2019
@daniel-wer daniel-wer deleted the speed-up-mapping-creation branch May 21, 2019 14:52
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