You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In this FITS file reading out the .data object of the 6th (0-indexed counting), the HDU named "Observation" takes over 3 minutes on my iMac 5K.
The table indicates a total size of 16 MB:
data.itemsize16777661
but I don't believe that should be an issue, as indicated by our IDL reader, that has no noticeable delay in opening that file.
In case this is not an easy-to-fix performance bug with pyfits: Our group is creating these files, we can't change the structure of the files in terms of where is stored what, but maybe there are some flags that we can use to improve the structure internally on the binary level somehow?
How do you define row? len(data) is 1, yes, but there's lot's of stuff in it. My system is OSX, Miniconda distribution, both Python 2 and 3 show this. Will try with github astropy now.
It's not that I think it's your computer. I just want to narrow down things like the Numpy version, etc. The OS could matter too.
Actually, instead of going straight to kernprof (since I'm not really sure what functions you need to be profiling) it might be nice if you made a simple test script that simply opens that file and loads the data (such that it demonstrates the slowdown), and then run python -m cProfile --sort=cumtime test_script.py and copy the basic profiler output first. Might help give an idea....
For reference, Michael's table has 22 fields, so in the process of reading and printing the table each field is accessed twice (I think for pyfits anyways this is normal). Each field access is taking almost 13 seconds on my system. Times 44 that's nearly 10 minutes right there... :(
At the same time, I made a plain Numpy array using the same dtype as that table and didn't have any noticeable problem. So maybe there's something crazy going on at our side too....
Probably the best one can do right now is to see if one can construct an equivalent recarray-only case which clearly still is much slower on master than on 1.9, and then post it to numpy/numpy#6467.
Sorry, it seems I'm getting in a habit of commenting when you are just writing what I thought... So, partly it is on our side, although the number of calls to things in _internal.py seem more than a little strange. Line 366 in that file is:
def _get_all_field_offsets(dtype, base_offset=0):
...
fields.extend((typ, off + dtype.base.itemsize*j)
for j in range(count) for (typ, off) in sub_offsets)
It is part of a section that was changed in the PR that made recarray so slow. cc @ahaldane just in case he has ideas.
@esheldonnumpy/numpy#6208 has been merged, and that's the only fix to this I'm aware of? Or is there another. I confirmed that I was testing against it.
@mhvk The test case I just added in numpy/numpy#6467 (comment) is totally independent of anything particularly weird astropy does (except maybe assigning a new dtype to an existing array but with a different byte order?)
@michaelaye - with the recent versions of numpy master and maintenance/1.10.x (see numpy/numpy#6562) this issue is resolved on my system. So, I'm closing this, but feel free to reopen if it turns out there still is a problem (if so, also note at numpy/numpy#6467). And: thanks for the report -- nice to see us helping numpy get better! -- or at least not get worse...
Activity
michaelaye commentedon Oct 21, 2015
Note, that I tried if gunzipping the file makes any difference, and it doesn't, AFAICS.
embray commentedon Oct 22, 2015
Weird--the data loaded immediately for me. You'll have to tell me more about the Python version and the platform.
embray commentedon Oct 22, 2015
Just to make sure I have the right data, is the table in question supposed to have only one row?
michaelaye commentedon Oct 22, 2015
How do you define row?
len(data)is 1, yes, but there's lot's of stuff in it. My system is OSX, Miniconda distribution, both Python 2 and 3 show this. Will try with github astropy now.michaelaye commentedon Oct 22, 2015
Just look at
data.namesto see all the tables in there:michaelaye commentedon Oct 22, 2015
It's really weird, even with 1-element fields though, it takes 3 seconds!! or so to get the prompt back when I do:
embray commentedon Oct 22, 2015
Yes, there's one row with many multi-element fields. Loading the table, or any individual column, took under a second for me.
Have you ever used kern_prof?
michaelaye commentedon Oct 22, 2015
Just so that you don't think it's my computer, I did the same with another file:
michaelaye commentedon Oct 22, 2015
No experience with kern_prof, but willing to learn. I tried with astropy master, to no avail.
embray commentedon Oct 22, 2015
It's not that I think it's your computer. I just want to narrow down things like the Numpy version, etc. The OS could matter too.
Actually, instead of going straight to kernprof (since I'm not really sure what functions you need to be profiling) it might be nice if you made a simple test script that simply opens that file and loads the data (such that it demonstrates the slowdown), and then run
python -m cProfile --sort=cumtime test_script.pyand copy the basic profiler output first. Might help give an idea....michaelaye commentedon Oct 22, 2015
I used pandas.show_versions() for the current stuff in miniconda:
embray commentedon Oct 22, 2015
Oh I see, this is your problem:
Let me see if this is fixed in #4228
michaelaye commentedon Oct 22, 2015
Wow, never would have thought that. Thanks!
12 remaining items
embray commentedon Oct 22, 2015
Yeah, even on numpy master it's still spending an incredible amount of time in those functions:
For reference, Michael's table has 22 fields, so in the process of reading and printing the table each field is accessed twice (I think for pyfits anyways this is normal). Each field access is taking almost 13 seconds on my system. Times 44 that's nearly 10 minutes right there... :(
embray commentedon Oct 22, 2015
At the same time, I made a plain Numpy array using the same dtype as that table and didn't have any noticeable problem. So maybe there's something crazy going on at our side too....
mhvk commentedon Oct 22, 2015
Probably the best one can do right now is to see if one can construct an equivalent recarray-only case which clearly still is much slower on master than on 1.9, and then post it to numpy/numpy#6467.
mhvk commentedon Oct 22, 2015
Sorry, it seems I'm getting in a habit of commenting when you are just writing what I thought... So, partly it is on our side, although the number of calls to things in
_internal.pyseem more than a little strange. Line 366 in that file is:It is part of a section that was changed in the PR that made
recarrayso slow. cc @ahaldane just in case he has ideas.esheldon commentedon Oct 22, 2015
Note the fix has not been merged into numpy master yet
embray commentedon Oct 22, 2015
@esheldon numpy/numpy#6208 has been merged, and that's the only fix to this I'm aware of? Or is there another. I confirmed that I was testing against it.
@mhvk The test case I just added in numpy/numpy#6467 (comment) is totally independent of anything particularly weird astropy does (except maybe assigning a new dtype to an existing array but with a different byte order?)
esheldon commentedon Oct 22, 2015
@embray Yeah, sorry, I thought I was getting email updates about that that pull request but I wasn't.
mhvk commentedon Oct 22, 2015
@embray - good that you could narrow it down. Hopefully, there will be a fix soon.
Added changelog entries for the working fixes in astropy#4228, and al…
mhvk commentedon Oct 27, 2015
@michaelaye - with the recent versions of numpy master and maintenance/1.10.x (see numpy/numpy#6562) this issue is resolved on my system. So, I'm closing this, but feel free to reopen if it turns out there still is a problem (if so, also note at numpy/numpy#6467). And: thanks for the report -- nice to see us helping numpy get better! -- or at least not get worse...
Added changelog entries for the working fixes in astropy#4228, and al…