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

Add LimitStore (#2175) #2242

Merged
merged 3 commits into from
Jul 31, 2022
Merged

Add LimitStore (#2175) #2242

merged 3 commits into from
Jul 31, 2022

Conversation

tustvold
Copy link
Contributor

Which issue does this PR close?

Part of #2175.

Rationale for this change

What changes are included in this PR?

Adds LimitStore

Are there any user-facing changes?

No, a future PR will remove this functionality from the AWS implementation

@github-actions github-actions bot added the object-store Object Store Interface label Jul 30, 2022
@codecov-commenter
Copy link

codecov-commenter commented Jul 30, 2022

Codecov Report

Merging #2242 (12d584e) into master (f41fb1c) will increase coverage by 0.00%.
The diff coverage is 81.25%.

@@           Coverage Diff           @@
##           master    #2242   +/-   ##
=======================================
  Coverage   82.30%   82.30%           
=======================================
  Files         241      242    +1     
  Lines       62437    62517   +80     
=======================================
+ Hits        51389    51457   +68     
- Misses      11048    11060   +12     
Impacted Files Coverage Δ
object_store/src/aws.rs 0.00% <ø> (ø)
object_store/src/lib.rs 86.75% <ø> (ø)
object_store/src/limit.rs 81.25% <81.25%> (ø)
arrow/src/array/builder/decimal_builder.rs 86.09% <0.00%> (-0.19%) ⬇️
arrow/src/datatypes/datatype.rs 62.61% <0.00%> (-0.08%) ⬇️
parquet_derive/src/parquet_field.rs 65.98% <0.00%> (ø)
...rquet/src/arrow/record_reader/definition_levels.rs 89.02% <0.00%> (+1.68%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us.

@@ -684,6 +684,7 @@ impl AmazonS3Builder {

/// Sets the maximum number of concurrent outstanding
/// connectons. Default is `16`.
#[deprecated(note = "use LimitStore instead")]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a nice side-effect of #2204, we can deprecate individual things now


/// Store wrapper that wraps an inner store and limits the maximum number of concurrent
/// object store operations. Where each call to an [`ObjectStore`] member function is
/// considered a single operation, even if it may result in more than one network call
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is worth highlighting the implementation of this functionality for S3 has the same property, despite calling it a connection limit

Copy link
Contributor

Choose a reason for hiding this comment

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

An example in this doc of how to construct a LimitStore might be helpful

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

LGTM -- thanks @tustvold


/// Store wrapper that wraps an inner store and limits the maximum number of concurrent
/// object store operations. Where each call to an [`ObjectStore`] member function is
/// considered a single operation, even if it may result in more than one network call
Copy link
Contributor

Choose a reason for hiding this comment

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

An example in this doc of how to construct a LimitStore might be helpful

}

impl<T: ObjectStore> LimitStore<T> {
/// Create new limit store
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// Create new limit store
/// Create new limit store that will limit the maximum
/// number of outstanding concurrent requests to
/// `max_requests`


impl<T: ObjectStore> std::fmt::Display for LimitStore<T> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "LimitStore({})", self.inner)
Copy link
Contributor

Choose a reason for hiding this comment

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

including max_requests would also be helpful here

#[async_trait]
impl<T: ObjectStore> ObjectStore for LimitStore<T> {
async fn put(&self, location: &Path, bytes: Bytes) -> Result<()> {
let _permit = self.semaphore.acquire().await.unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

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

I double checked if we needed to check the error here -- https://docs.rs/tokio/1.20.1/tokio/sync/struct.Semaphore.html#method.acquire says that errors are only returned if the Semaphore is closed, which this code does not do 👍


let t = Duration::from_millis(1);

// Expect to not be able to make another request
Copy link
Contributor

Choose a reason for hiding this comment

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

👍 I am always a little worried when I see a sleep style thing in a test as I worry about intermittent failures due to timing differences, but this use seems sound 👍

Maybe we can bump the timeout up to 20ms or something to be safe on slow machines

Copy link
Contributor Author

Choose a reason for hiding this comment

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

FWIW as this is a timeout all a slow machine could potentially mean is that the test erroneous passes, when it should have failed. I'll bump the timeout to be on the safe side

@alamb
Copy link
Contributor

alamb commented Jul 31, 2022

Screen Shot 2022-07-31 at 7 09 19 AM

As an aside, if I may toot my own horn, the changes from #2149 seem to be working well and this PR only runs a small subset of the total CI checks :bowtie:

@tustvold tustvold merged commit 6c3f9a2 into apache:master Jul 31, 2022
@ursabot
Copy link

ursabot commented Jul 31, 2022

Benchmark runs are scheduled for baseline = 281cd79 and contender = 6c3f9a2. 6c3f9a2 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Skipped ⚠️ Benchmarking of arrow-rs-commits is not supported on ec2-t3-xlarge-us-east-2] ec2-t3-xlarge-us-east-2
[Skipped ⚠️ Benchmarking of arrow-rs-commits is not supported on test-mac-arm] test-mac-arm
[Skipped ⚠️ Benchmarking of arrow-rs-commits is not supported on ursa-i9-9960x] ursa-i9-9960x
[Skipped ⚠️ Benchmarking of arrow-rs-commits is not supported on ursa-thinkcentre-m75q] ursa-thinkcentre-m75q
Buildkite builds:
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
object-store Object Store Interface
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants