-
-
Notifications
You must be signed in to change notification settings - Fork 175
[mycpp] POSIX I/O experiment #2577
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
base: master
Are you sure you want to change the base?
Conversation
1a746a1 to
9433cf5
Compare
|
There are still a few correctness issues left that I can't quite figure out, but benchmarks show that without buffering I/O (and reading byte-by-byte) we are definitely slower than |
9433cf5 to
8364b85
Compare
|
Hmm this is a very good experiment! Thank you And it highlights that the only thing we really use is Let me see what other shells do for reading a line I will started a thread on Zulip |
Signed-off-by: Andrii Sultanov <[email protected]>
8364b85 to
ebee115
Compare
Magic of POSIX I/O! Signed-off-by: Andrii Sultanov <[email protected]>
4000146 to
8df12fc
Compare
|
Implemented buffering - seems to be mostly functional. There's this odd error in Some of the |
The algorithm is as follows: 1. Fill the buffer 2. Move through the buffer (incrementing pos_), separating it into segments split by newlines. Return the next segment on each call 3. If newline is not found and we are in the middle of the buffer, move the segment since the last newline to the start of the buffer and fill the rest, move to 2. 4. If newline is not found and we are in the beginning of the buffer (no newlines seen previously), this line is too long. 5. If EOF is seen when filling the buffer, return the buffer as a single segment Signed-off-by: Andrii Sultanov <[email protected]>
8df12fc to
2f86cea
Compare
|
Figured out the |
|
Buffering certainly improved performance from the one-byte read implementation, but there's some way to go to get the libc i/o perf. Table of bash ratios: Buffering benchmarks: https://op.oilshell.org/uuu/github-jobs/10880/benchmarks3.wwz/_tmp/osh-runtime/index.html |
|
Ah OK interesting ... I think looking at end-to-end benchmarks is good, but we could also write some more focused benchmarks Although maybe first, I'm not sure why we can use our own buffering, but we can't use libc's buffering? BTW buffering may relate to our |
|
Hm, so at a high level, would this lead to a fix for both
? I may have paged the details out of memory ... |
|
opening to see how this runs in the CI.
this is a very naive implementation where we read the file byte-by-byte to see how this fares in the benchmarks as the worst possible case.
next step - implement our own buffering (most importantly, it needs to support native
dup-ing, preserving the buffer and the current seek position)