cargo-bins / cargo-binstall

Binary installation for rust projects
GNU General Public License v3.0
1.65k stars 62 forks source link

`AsyncExtracter` TODOs #170

Closed NobodyXu closed 2 years ago

NobodyXu commented 2 years ago

A summary of what could be/need to be improved:

NobodyXu commented 2 years ago

For thread-safe spsc, I found:

Both provides a sync interface but should be trivial to adapt them in async by using tokio::sync::Notify.

Edit:

Maybe this will be proved to be a premature optimization, so perhaps we should try the 1st TODO to adjust size of mpsc::channel before trying SPSC.

NobodyXu commented 2 years ago

I am thinking about running the downloader in the same blocking thread as the extracter using tokio::runtime::Handle.

This would have the following advantage:

The disadvantages would be that the downloader can no longer be run in parallel to the extracter.

If the bottleneck is the decompressor, then the downloader should also pause and wait for the decompressor to consume the data.

But if the bottleneck is the network, then that might be an issue.

@passcod What's your thought on this?

NobodyXu commented 2 years ago

Alternatively, we can do:

Compared to the previous approach I proposed, this preserve the parallelism between the downloader and the extracter, while reduce the internal buffer of mpsc and make it possible for the downloader and extracter to be run on the same thread (though not guaranteed).