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

Move mandlebrot to web worker in tiled heatmap story #1124

Merged
merged 2 commits into from
May 25, 2022
Merged

Conversation

axelboc
Copy link
Contributor

@axelboc axelboc commented May 25, 2022

I've found a library called greenlet, which works beautifully. It creates an inline worker with the function you give it: https://github.com/developit/greenlet and wraps it in a promise API. It's super tiny too.

The demo is a lot more fluid, though still not amazing on my machine, as we're still doing all the computations on the CPU. It can't compare exactly to a fetch-based scenario, but it's already a lot better.


const array = ndarray(new Float32Array(height * width), [height, width]);
const array = new Float32Array(height * width);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can't use ndarray inside the worker because of the way greenlet works. It's limited to functions that don't rely at all on external scope.

@axelboc axelboc requested review from t20100 and loichuder May 25, 2022 11:43
Base automatically changed from up-pnpm to main May 25, 2022 11:52
Copy link
Member

@loichuder loichuder left a comment

Choose a reason for hiding this comment

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

Much smoother on my end

@axelboc axelboc merged commit bcb98d3 into main May 25, 2022
@axelboc axelboc deleted the web-worker branch May 25, 2022 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants