Skip to content

Switch to one single runtime for S3 storage #909

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

Merged
merged 2 commits into from
Jul 25, 2020

Conversation

Kixiron
Copy link
Member

@Kixiron Kixiron commented Jul 25, 2020

  • Made S3Backend::start_storage_transaction stop creating a new Runtime on each call
  • Added parking_lot as a direct dependency (was a transitive dependency)

This should allow updating tokio to v0.2 without the "fun little bugs" and hopefully allow async to actually be achievable

Changed S3Backend::start_storage_transaction from creating a new Runtime on each call to using a lazily-initialized global runtime for all S3 instances to use.
Since Tokio v0.1's Runtime has no mechanism to allow for blocking that doesn't require an &mut self, the runtime is stored inside of a mutex to allow for
mutable access. We're already transitively dependent on parking_lot v0.10.2, so this is just adding it as a direct dependency (Removing tokio v0.2 will remove the other)
version of parking_lot we depend on). When upgrading to tokio v0.2 this should be changed since v0.2 has the Runtime::handle method which allows runtime access from only &self.
@Kixiron Kixiron added S-waiting-on-review Status: This pull request has been implemented and needs to be reviewed P-high High priority C-technical-debt Category: This makes the code harder to read and modify, but has no impact on end users A-backend Area: Webserver backend labels Jul 25, 2020
@Kixiron Kixiron requested a review from jyn514 July 25, 2020 00:59
@jyn514 jyn514 added the A-builds Area: Building the documentation for a crate label Jul 25, 2020

pub(crate) struct S3Backend {
client: S3Client,
bucket: String,
runtime: &'static Mutex<Runtime>,
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason to make this part of S3Backend instead of using S3_RUNTIME.lock().block_on() directly?

Copy link
Member Author

Choose a reason for hiding this comment

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

It was based off of this comment

Copy link
Member

Choose a reason for hiding this comment

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

Gotcha. Looking at the code I don't think it's actually necessary, we can change it to be a field as part of the switch to tokio 0.2 but for now I think it's more clear to use the Lazy directly.

@jyn514 jyn514 merged commit a8f046a into rust-lang:master Jul 25, 2020
@Kixiron Kixiron deleted the uno-runtime branch July 25, 2020 02:15
@Kixiron Kixiron mentioned this pull request Jul 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-backend Area: Webserver backend A-builds Area: Building the documentation for a crate C-technical-debt Category: This makes the code harder to read and modify, but has no impact on end users P-high High priority S-waiting-on-review Status: This pull request has been implemented and needs to be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants