Open
Conversation
Collaborator
Author
|
Reopening this in light of having a more realistic "tight |
Still incomplete; failing test case illustrates the remaining bug
64361a8 to
a23a7a0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a performance optimization that's normally insignificant; occasionally good, in tight
%readloops; and very rarely negative, when those tight%readloops work on a file with mostly zero-to-one character lines. Generally the performance improvement increases as line lengths increase, which shouldn't be a surprise. Files with pretty short lines, like/usr/share/dict/words, see a measurable improvement with tight%readloops, though.In theory, it seems to me the overhead of the extra
lseek()calls (which are the source of the negative effects, where they appear) could be reduced by caching the seekability of fds. Maybe just one such value, assuming performance-sensitive calls to%readare typically done repeatedly in a loop (and on a single fd).This introduces an awkward performance asymmetry, sadly, between the cases of
cat foo | the_scriptandthe_script < foo, since stdin in the former case is non-seekable from a pipe, while in the latter case it's seekable.I'm not married to this proposal. Just wanted to put it out there. I'm not very good at speedy code so there's very possibly a better way to do this than I've got here :)