Repository navigation
Adding performance message for Table.read with memmap=True - #9404
Conversation
|
|
||
| >>> tm.write('tm.ecsv', overwrite=True, serialize_method='data_mask') # doctest: +SKIP | ||
|
|
||
| Reading a ``.fits`` in |Table| using |
There was a problem hiding this comment.
Should be Read a large FITS file in ..., and same further down read a large FITS file. For small files using memmap=True will likely degrade performance.
There was a problem hiding this comment.
The text still refers to reading a .fits, that needs to be FITS file.
|
Thanks, @taldcroft. Everything done as suggested |
|
@himanshupathak21061998 - Thanks! From this docs addition, I don't think I would have understood when to use @saimn explained the key points in #8573 (comment) and showed examples in https://github.com/saimn/misc-astro/blob/master/astropy/Table_memmap.ipynb
Suggest to reword the explanation and recommendation along those lines. |
5b27e44 to
b408ef9
Compare
|
@cdeil Should I also include outputs of |
|
@himanshupathak21061998 - My suggestion would be to not include a fully worked example, including how to measure with I think a short explanation like this contains all the infos? |
|
@cdeil I think hdf5 also does not support Code to reproduce |
cdeil
left a comment
There was a problem hiding this comment.
@himanshupathak21061998 - A few typos / grammar suggestions inline. Otherwise I'm happy with this now. Thanks!
I'm not sure if the statement on HDF5 is correct. It might always use memmap under the hood. You could try to find out by measuring memory use when reading a row or column subset, or by reading the code. Or others reviewing the PR here like @taldcroft will know for sure.
| -------------------------- | ||
|
|
||
| By default :meth:`~astropy.table.Table.read` will read the whole table into memory, which | ||
| will take a lot of memory and can take a lot of time, depending on the table size and |
| Length = 100 rows | ||
| >>> col = table["my_column"] # Will load all table into memory | ||
|
|
||
| Right now :meth:`~astropy.table.Table.read` does not supports ``memmap=True`` for HDF5 and ASCII |
|
|
||
| >>> tm.write('tm.ecsv', overwrite=True, serialize_method='data_mask') # doctest: +SKIP | ||
|
|
||
| Read FILE with memmap=True |
|
@taldcroft , since you requested changes, can you please give this one another look? Thanks! |
|
|
||
| By default :meth:`~astropy.table.Table.read` will read the whole table into memory, which | ||
| can take a lot of memory and can take a lot of time, depending on the table size and | ||
| file format. In some cases, it's possibly to only read a subset of the table by choosing |
There was a problem hiding this comment.
| file format. In some cases, it's possibly to only read a subset of the table by choosing | |
| file format. In some cases, it's possible to only read a subset of the table by choosing |
There was a problem hiding this comment.
It might be useful to clarify the "In some cases". I think that the table will always be loaded fully in memory if one column must be converted to another format, i.e. when there is a boolean column, or when some column must be scaled.
This is if I remember correctly the discussions on @astrofrog 's PR, so maybe he remembers better than me ;).
| ... 'b': np.arange(1e7, dtype=float), | ||
| ... 'c': np.arange(1e7, dtype=float)}) | ||
| >>> tbl.write('test.fits', overwrite=True) | ||
| >>> table = Table.read("test.fits", memmap=True) # Very fast, doesn't actually load data |
There was a problem hiding this comment.
Nitpick but it's better to be consistent with the other lines:
| >>> table = Table.read("test.fits", memmap=True) # Very fast, doesn't actually load data | |
| >>> table = Table.read('test.fits', memmap=True) # Very fast, doesn't actually load data |
| 98.0 98.0 98.0 | ||
| 99.0 99.0 99.0 | ||
| Length = 100 rows | ||
| >>> col = table["my_column"] # Will load all table into memory |
There was a problem hiding this comment.
| >>> col = table["my_column"] # Will load all table into memory | |
| >>> col = table['my_column'] # Will load all table into memory |
|
I am deferring to @saimn . 😬 |
|
Yes, looks good to me. Thanks @himanshupathak21061998! |
|
Should let the |
|
The doctest is skipped, so I would say #yolo and merge this now. |
pllim
left a comment
There was a problem hiding this comment.
I made a commit of nitpicks and triggered the CI. If it passed (I think it should), then this LGTM. Since @taldcroft and @saimn already unofficially approved it, I am going to officially do it here.
But I'll let it stay open a bit more in case @lglattly wants to copy-edit.
lglattly
left a comment
There was a problem hiding this comment.
Some small copy editing suggestions, looks good to me otherwise!
Co-Authored-By: lglattly <[email protected]>
|
I think tests failures are unrelated to this pr 😕 |
The review has been addressed, and reviewer was happy with the PR in his latest comment.
|
mpl related CI failures are indeed unrelated, so I'm merging this now given the overall approval above. Thanks @himanshupathak21061998! |
Description
This pull request is to address ...
Fixes #8573
I added an example in performance docs to show an efficient way to use
Table.read().