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

Serialize asynchronous evaluation to improve performance #1469

Closed
Fil opened this issue Jun 17, 2024 · 2 comments · Fixed by #1748
Closed

Serialize asynchronous evaluation to improve performance #1469

Fil opened this issue Jun 17, 2024 · 2 comments · Fixed by #1748
Labels
enhancement New feature or request

Comments

@Fil
Copy link
Contributor

Fil commented Jun 17, 2024

sql queries —using the function in js code blocks, or within sql code blocks— can depend on variables that change often, such as the value of an interactive range slider.

The performance of these queries can suffer from the sheer quantity of queries sent during interaction, as they need to be executed in turn. Furthermore, it is a huge waste of compute, since all the queries but the last correspond to an invalidated state of the cell, and are discarded after execution.

This problem generalizes to all asynchronous functions.

Registering asynchronous functions per cell—so that each cell only runs one query at a time, and skips the queries launched by cells that have been invalidated—could lead to a dramatic performance boost.

@Fil Fil added the enhancement New feature or request label Jun 17, 2024
@mbostock mbostock changed the title Register asynchronous functions for interactive performance Serialize asynchronous evaluation to improve performance Jun 17, 2024
@mbostock
Copy link
Member

mbostock commented Jun 17, 2024

This is mostly a problem with DuckDB-Wasm or anything that’s using web workers to compute asynchronously; if the computation is running in the main thread, it tends to be serialized anyway because JavaScript is single-threaded; though there are equivalent problems if a cell is e.g. calling fetch: you’ll make many fetches that are discarded only to consider the response of the last one.

What we want here is an opt-in or opt-out mechanism that makes it easy to serialize computation, so that we don’t compute a variable too many times in parallel and waste resources.

@Fil
Copy link
Contributor Author

Fil commented Jul 8, 2024

I've applied it to https://observablehq.observablehq.cloud/pangea/varia/lap-jv which was otherwise crashing when you moved the slider "too much".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants