Skip to content

Throw an exception when the data buffer size for allocation is too large #2155

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

kounelisagis
Copy link
Member

Let's throw an exception for the cases that the total domain size overflows a uint64, and the estimator returns the maximum amount of data that can be read at once (UINT64_MAX).

@@ -98,6 +98,10 @@ struct BufferInfo {
try {
dtype = tiledb_dtype(data_type, cell_val_num);
elem_nbytes = tiledb_datatype_size(type);
if (data_nbytes >
static_cast<uint64_t>(std::numeric_limits<intptr_t>::max())) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is good and it is a step forward. We should merge this PR with at least this change.

However, boxes will OOM long before request sizes approach 2^63. I don't want us to hard-code assumptions about RAM sizes (AWS offers instances with a terabyte of RAM which is 2^40!). Just food for thought, maybe we can make a cap smaller than int64 max. Just a thought.

Copy link
Member

Choose a reason for hiding this comment

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

Ideally if numpy has a defined maximum size for its arrays (like .NET has) we would check that, but I couldn't find it after a search.

Copy link
Member

Choose a reason for hiding this comment

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

I was thinking and discussed with Agis that we could make this max something safe enough, like e.g. 2GB?, and make it configurable through a py. config, similar to what we are able to do today with incomplete buffer sizes through cfg["py.max_buffer_bytes"].

Then we could improve also the user experience, by suggesting to him when we throw to increase that config value or use A.query(incomplete=True) to read his data.

Copy link
Member

Choose a reason for hiding this comment

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

A 2GB default limit sounds fine, and can be overridden with an optional parameter like A.query(ignore_buffer_size_check=True). Customizing it with a config option sounds like an overkill.

Users should really use incomplete queries if possible, and way before the 2GB threshold. Allocating contiguous buffers of this size has disadvantages like memory fragmentation.

Copy link
Member Author

Choose a reason for hiding this comment

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

We also have the (undocumented?) py.alloc_max_bytes, as discussed with @ihnorton. I will take a look at it.


with tiledb.open(uri, mode="r") as A:
with pytest.raises(OverflowError) as exc:
A[:]
Copy link
Member

Choose a reason for hiding this comment

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

That's probably another issue to look at, but why would we even allocate a user buffer for retrieving results from an empty array?

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.

4 participants