Skip to content

Add ObjectStore::get_ranges (#2293)#2336

Merged
tustvold merged 3 commits intoapache:masterfrom
tustvold:add-get-ranges
Aug 8, 2022
Merged

Add ObjectStore::get_ranges (#2293)#2336
tustvold merged 3 commits intoapache:masterfrom
tustvold:add-get-ranges

Conversation

@tustvold
Copy link
Contributor

@tustvold tustvold commented Aug 5, 2022

Which issue does this PR close?

Closes apache/arrow-rs-object-store#239

Rationale for this change

What changes are included in this PR?

Are there any user-facing changes?

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.

Code looks good to me -- I had some suggestion about coalscing in the default impl and some additional test cases that I think would be valuable to consider

cc @Ted-Jiang and @thinkharderdev

Comment on lines 241 to 245
let mut out = Vec::with_capacity(ranges.len());
for range in ranges {
out.push(self.get_range(location, range.clone()).await?)
}
Ok(out)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not use coalsce_ranges here as the default implementation? That would likely perform better for user supplied object store implementations, and this PR could likely get smaller too as AWS, GCP, etc would not have to be modified

Suggested change
let mut out = Vec::with_capacity(ranges.len());
for range in ranges {
out.push(self.get_range(location, range.clone()).await?)
}
Ok(out)
coalesce_ranges(
ranges,
|range| self.get_range(location, range),
OBJECT_STORE_COALESCE_DEFAULT,
)
.await

Copy link
Member

Choose a reason for hiding this comment

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

Yea, coalsce_ranges looks should outperform current default implementation. Looks good to use it as default one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess I was concerned that some implementations may not benefit from this, but then again perhaps those cases should override this 🤔

}

/// Range requests with a gap less than or equal to this,
/// will be coalesced into a single request
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
/// will be coalesced into a single request
/// will be coalesced into a single request by [`coalesce_ranges`]

/// Range requests with a gap less than or equal to this,
/// will be coalesced into a single request
#[cfg(any(feature = "azure", feature = "aws", feature = "gcp"))]
pub const OBJECT_STORE_COALESCE_DEFAULT: usize = 10 * 1024;
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. As suggested above, I think this would be useful for all implementations rather than just the built in ones azure, aws and gcp (and thus we could avoid this feature flag)
  2. I am not sure if there is any value to exposing this constant -- I would recommend initially keeping it pub(crate)

Copy link
Member

Choose a reason for hiding this comment

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

agree, like 'HDFS' usually fetch 64MB as one batch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Perhaps I should bump this to 1MB?

let fetches = do_fetch(vec![0..1, 56..72, 73..75], 1).await;
assert_eq!(fetches, vec![0..1, 56..75]);

let fetches = do_fetch(vec![0..1, 5..6, 7..9, 2..3, 4..6], 1).await;
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

fetches
};

let fetches = do_fetch(vec![0..1, 1..2], 0).await;
Copy link
Contributor

Choose a reason for hiding this comment

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

I recommend also testing:

ranges (do_fetch(vec![]))

"off by one" coalsce":

  1. fetches, vec![0..2, 3..5]), // no coalsce
  2. fetches, vec![0..2, 2..5]), // no coalsce

Copy link
Contributor

@thinkharderdev thinkharderdev left a comment

Choose a reason for hiding this comment

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

Nice!

Copy link
Member

@Ted-Jiang Ted-Jiang left a comment

Choose a reason for hiding this comment

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

Thanks @tustvold really need this API 👍

@tustvold tustvold merged commit 9a630a1 into apache:master Aug 8, 2022
@ursabot
Copy link

ursabot commented Aug 8, 2022

Benchmark runs are scheduled for baseline = 0c828a9 and contender = 9a630a1. 9a630a1 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

alamb pushed a commit to alamb/arrow-rs that referenced this pull request Mar 20, 2025
* Add ObjectStore::get_ranges (#2293)

* Review feedback
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support get_multi_ranges in ObjectStore

6 participants