Skip to content
This repository has been archived by the owner on Sep 12, 2023. It is now read-only.

Spawn wallet actor as a blocking task #2469

Merged
merged 1 commit into from
Jul 19, 2022

Conversation

Restioson
Copy link
Collaborator

@Restioson Restioson commented Jul 19, 2022

This is solution 2 to #2453. It spawns the wallet actor as a blocking task. I am not 100% sure if this will correctly make the thread park when nothing is being sent to the wallet actor.

@Restioson Restioson force-pushed the wallet-actor-blocking branch from f48eb9d to 9c84181 Compare July 19, 2022 10:36
Copy link
Contributor

@luckysori luckysori left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to try this!

@Restioson
Copy link
Collaborator Author

I am currently preferring this solution over comit-network/xtra-productivity#7 since it's easier to verify that everything works correctly. comit-network/xtra-productivity#7 might be helpful in the future if there are actors which have a mix of sync and async actors, but the wallet only has sync handlers, so there the point is moot.

@Restioson Restioson requested review from da-kami and klochowicz July 19, 2022 10:38
Copy link
Contributor

@klochowicz klochowicz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would you mind adding a bit more info into the commit description? it's a significant find, some context would be great :) thanks!

@da-kami
Copy link
Contributor

da-kami commented Jul 19, 2022

I just noticed that the macos tests were running for 15 minutes before finishing. That is quite some CI time 😅
I doubt that this is related to the PR.

@Restioson
Copy link
Collaborator Author

would you mind adding a bit more info into the commit description? it's a significant find, some context would be great :) thanks!

Sure!

@Restioson Restioson force-pushed the wallet-actor-blocking branch from 9c84181 to d82f32b Compare July 19, 2022 11:18
@Restioson
Copy link
Collaborator Author

I've realised that this has the side effect of no longer being added to the Tasks struct in the taker and maker main functions - this should be okay, though, since when the main thread exits it should kill the other thread too.

@klochowicz
Copy link
Contributor

@Restioson it seems clippy complains about some unused import now

The wallet actor performs a lot of CPU-bound, blocking work in its handlers. This is
bad, as it currently runs on the tokio runtime, which explicitly forbids blocking like
this. It also does not have any asynchronous handlers, so this commit makes the wallet
actor run on a separate thread which blocks on the execution of the actor's future.
@Restioson Restioson force-pushed the wallet-actor-blocking branch from d82f32b to 8b6a57b Compare July 19, 2022 11:42
@Restioson
Copy link
Collaborator Author

Fixed too :)

@klochowicz
Copy link
Contributor

I've realised that this has the side effect of no longer being added to the Tasks struct in the taker and maker main functions - this should be okay, though, since when the main thread exits it should kill the other thread too.

we never documented the purpose of Tasks struct in main.rs anywhere, but as far as I remember this was slightly different concern at play as clearly the tasks/threads will exit when the main thread does.

What we had to deal with here is to ensure we drop all the references to some resources (notably the DB) so that we could close it without errors. In wallet case, we don't use the DB, so it should not matter anyway.

@klochowicz
Copy link
Contributor

bors r+

@bors bors bot merged commit b58d72c into get10101:master Jul 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants