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

Barbara compares some cpp code (and has a performance problem) #144

Merged
merged 6 commits into from
Apr 18, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/vision/status_quo/barbara_compares_some_cpp_code.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ would have probably required figuring out how to use `perf` or some similar tool

## 🤔 Frequently Asked Questions

### **Is this actually the correct solution?**
* Only in part. It may cause other kinds of contention or blocking on the runtime. The deserialization work probably needs to be wrapped in something like [`block_in_place`](https://docs.rs/tokio/1.5.0/tokio/task/fn.block_in_place.html), so that other tasks are not starved on the runtime, or might want to use [`spawn_blocking`](https://docs.rs/tokio/1.5.0/tokio/task/fn.spawn_blocking.html). There are some important caveats/details that matter:
* This is dependent on how the runtime works.
* `block_in_place` + `tokio::spawn`/`spawn_blocking` might be better if the caller wants to control concurrency, as spawning is heavyweight when the deserialization work happens to be small.
* `spawn_blocking`, at least in some executors, cannot be cancelled, a departure from the prototypical cancellation story in async Rust.
* "Dependently blocking work" in the context of async programming is a hard problem to solve generally. https://github.com/async-rs/async-std/pull/631 was an attempt but the details are making runtime's agnostic blocking are extremely complex.
### **What are the morals of the story?**
* Producing concurrent, performant code in Rust async is not always trivial. Debugging performance
issues can be difficult.
Expand Down