Skip to content

Decide when it makes sense to use CPU-task thread pool

With !2678 (merged) , we're getting access to a thread-pool for CPU-intensive activities.

We should decide how CPU-intensive an activity needs to be in order for us to want to offload it to a worker thread. Obviously, solving a PoW puzzle is expensive enough that we should offload it -- and probably, decrypting a single RELAY cell is not expensive enough: but in the middle, we have all kinds of public key operations that might or might not be worth offloading.

I've found a post from Alice Rhyl that says:

To give a sense of scale of how much time is too much, a good rule of thumb is no more than 10 to 100 microseconds between each .await. That said, this depends on the kind of application you are writing.

We could adopt that as a heuristic, but maybe we'll want to think harder here.

cc @wesleyac