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

What should nbytes return? #167

Open
TomNicholas opened this issue Jun 29, 2024 · 2 comments · May be fixed by #227
Open

What should nbytes return? #167

TomNicholas opened this issue Jun 29, 2024 · 2 comments · May be fixed by #227
Labels
enhancement New feature or request

Comments

@TomNicholas
Copy link
Member

Xarray uses the optional property .nbytes to indicate the size of wrapped arrays. Currently we don't implement .nbytes on ManifestArrays, so xarray defaults to estimating the size as basically arr.size * arr.dtype.itemsize. I.e. currently it returns what the full size of the dataset would be if you loaded every referenced chunk into memory at once. But does this make sense for an array that can never be loaded into memory?

There is another completely different size to consider - that of the in-memory representation of the references - see discussion in #104. This is a known fixed number, it's not lazy-loading, but it's much smaller than the current nbytes.

This latter number is what's relevant if you're trying to estimate RAM usage whilst manipulating references, so it's possibly related to the __sizeof__ discussion in pydata/xarray#5764.

@TomNicholas TomNicholas linked a pull request Aug 23, 2024 that will close this issue
7 tasks
@dcherian
Copy link

But what if you did want to estimate total size of the dataset?

@TomNicholas
Copy link
Member Author

Yes, fair question, that doubt is why I haven't merged #227 yet.

Perhaps we should have two ways to display the size, one normal ds.nbytes and one using the accessor e.g. ds.virtualize.nbytes. I'm not sure whether it would be more intuitive to have the normal ds.nbytes be the actual in-memory size used or the memory that would be taken up by the whole dataset though.

@TomNicholas TomNicholas added the enhancement New feature or request label Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants