-
Notifications
You must be signed in to change notification settings - Fork 36
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
kounelisagis
wants to merge
2
commits into
main
Choose a base branch
from
agis/data-buffer-size-too-large
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -382,6 +382,26 @@ def test_sc62594_buffer_resize(self, array_data): | |
with tiledb.DenseArray(uri) as T: | ||
assert_array_equal(array_data, T) | ||
|
||
def test_data_buffer_too_large(self): | ||
uri = self.path("test_agis") | ||
dim1 = tiledb.Dim( | ||
name="dim_0", domain=(0, 10000000000), tile=512, dtype=np.int64 | ||
) | ||
dim2 = tiledb.Dim( | ||
name="dim_1", domain=(0, 10000000000), tile=512, dtype=np.int64 | ||
) | ||
att = tiledb.Attr(name="data", dtype="int8") | ||
schema = tiledb.ArraySchema( | ||
domain=tiledb.Domain(dim1, dim2), | ||
attrs=(att,), | ||
) | ||
tiledb.Array.create(uri, schema) | ||
|
||
with tiledb.open(uri, mode="r") as A: | ||
with pytest.raises(OverflowError) as exc: | ||
A[:] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? |
||
assert "Data buffer size is too large" in str(exc.value) | ||
|
||
|
||
class SOMA919Test(DiskTestCase): | ||
""" | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 throughcfg["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.There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.