Skip to content

PERF: some more perf/clean in saslib.pyx #12961

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

Closed
wants to merge 1 commit into from

Conversation

jreback
Copy link
Contributor

@jreback jreback commented Apr 22, 2016

more perf

cc @kshedden

@jreback jreback added Performance Memory or execution speed performance IO SAS SAS: read_sas labels Apr 22, 2016
@jreback jreback added this to the 0.18.1 milestone Apr 22, 2016
@jreback
Copy link
Contributor Author

jreback commented Apr 22, 2016

@kshedden if you can run this on your example would be great (it may only be a small speedup)

@kshedden
Copy link
Contributor

I'm getting ~2.99 seconds per 100K lines on the same file I have been using in #12656 (I think I was getting 3.1-3.2 seconds with the earlier version).

@kshedden
Copy link
Contributor

My test file is not compressed and many of your changes are in the decompression, so it would not have helped.

@jreback
Copy link
Contributor Author

jreback commented Apr 23, 2016

good point

do we have a compress file to test on ?

are those sas7cdat?

@@ -16,13 +19,13 @@ cdef np.ndarray[uint8_t, ndim=1] rle_decompress(int result_length, np.ndarray[ui

while ipos < length:
control_byte = inbuff[ipos] & 0xF0
end_of_first_byte = int(inbuff[ipos] & 0x0F)
end_of_first_byte = <uint8_t>(inbuff[ipos] & 0x0F)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we have to cast to regular int here (2 byte or wider), below there are places where end_of_first_byte is multiplied and will overflow.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure / do u have some test files for this ? if not ok too

@kshedden
Copy link
Contributor

end_of_first_byte needs to be an int I think (at least 2 bytes wide). Even though its value is copied out of a uint8 array it needs to be promoted to uint16 or it overflows later on. We have to be very careful in the decompressors about types. It's been a few months since I did this but there is a lot of subtle stuff in there and I spent a lot of trial and error getting it to work. The masking and shifting gets messed up if things are not exactly the right int type (too wide or too narrow both cause problems). I don't think this is covered well by our tests. These are very outdated and poorly documented compression algorithms. Most of the compression codes are rarely used except in larger files. To keep the test suite fast I created only small test files which don't hit all the compression codes.

@kshedden
Copy link
Contributor

Many of the files in our test suite are compressed, but they are small and don't necessarily use all the compression codes. Compressed SAS files have the same name extension as decompressed ones (sas7bdat). You might be thinking of sas7bcat which has categorical data labels (sas7bdat only supports floats and strings).

@jreback
Copy link
Contributor Author

jreback commented Apr 23, 2016

@kshedden ok I fixed up the byte construction. ideally we would have a test for this :>

will merge on your ok.

@jreback
Copy link
Contributor Author

jreback commented Apr 26, 2016

@kshedden ok with this?

@jreback
Copy link
Contributor Author

jreback commented Apr 27, 2016

@kshedden I merged in. lmk if any more issues (or if you have better test cases)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
IO SAS SAS: read_sas Performance Memory or execution speed performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants