Skip to content

Commit

Permalink
runtime: Use block_in_place to avoid exhausting the blocking pool
Browse files Browse the repository at this point in the history
  • Loading branch information
kostko committed Mar 14, 2023
1 parent 36e1ae9 commit 4abf809
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 12 deletions.
Empty file added .changelog/5223.trivial.md
Empty file.
6 changes: 2 additions & 4 deletions keymanager/src/client/remote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,12 +405,10 @@ impl KeyManagerClient for RemoteClient {

// Fetch current epoch.
let consensus_state = self.inner.consensus_verifier.latest_state().await?;
let consensus_epoch = tokio::task::spawn_blocking(move || {
let consensus_epoch = tokio::task::block_in_place(move || {
let beacon_state = BeaconState::new(&consensus_state);
beacon_state.epoch()
})
.await
.unwrap()?;
})?;

// First try to fetch from cache.
{
Expand Down
6 changes: 2 additions & 4 deletions runtime/src/attestation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,10 @@ impl Handler {
let consensus_verifier = self.consensus_verifier.clone();
let version = Some(self.version);
let runtime_id = self.runtime_id;
let policy = tokio::task::spawn_blocking(move || {
let policy = tokio::task::block_in_place(move || {
// Obtain current quote policy from (verified) consensus state.
PolicyVerifier::new(consensus_verifier).quote_policy(&runtime_id, version)
})
.await
.unwrap()?;
})?;

self.identity.set_quote_policy(policy)?;
}
Expand Down
6 changes: 2 additions & 4 deletions runtime/src/enclave_rpc/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,14 +314,12 @@ impl Session {

let consensus_state = consensus_verifier.latest_state().await?;
// TODO: Make this access async.
let node = tokio::task::spawn_blocking(move || -> Result<_> {
let node = tokio::task::block_in_place(move || -> Result<_> {
let registry_state = RegistryState::new(&consensus_state);
Ok(registry_state
.node(&node)?
.ok_or(SessionError::NodeNotRegistered)?)
})
.await
.unwrap()?;
})?;

let verified = node
.runtimes
Expand Down

0 comments on commit 4abf809

Please sign in to comment.