-
Notifications
You must be signed in to change notification settings - Fork 19
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
reverse_complement spends most of its time reading input #43
Comments
The C++ code uses long start = ftell( stdin );
fseek( stdin, 0, SEEK_END );
size = ftell( stdin ) - start; |
The C version uses a buffer that is |
@llogiq |
To avoid wasting memory, Also, with a 250 MB buffer, even a single reallocation can be a huge cost. I had to tack an extra byte onto the buffer size to avoid a single reallocation at the end of the file. |
@TeXitoi also depending on alignment and allocator used, |
On my system,
reverse_complement < input25000000.txt
spends 67% of its time on theread_to_end
call here. According to the profile, that time is almost all spent inmemmove
.Increasing the initial buffer size to fit the entire dataset cuts the
read_to_end
time in half, and reduces the total execution time by about 30%, but obviously it also wastes memory if the data is small. (Since this program reads from stdin, it doesn't known the total size before it starts reading.)The text was updated successfully, but these errors were encountered: