virtual_sdcard: fadvice reads#7168
Conversation
a4d0ef4 to
0ed04a4
Compare
For debug purporses Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
os.read() will block. It is therefore possible that it can block for a long time. Long enough to block the reactor and cause an TTC error. Advise OS to always readahead file to reduce the probability of the event. Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
0ed04a4 to
c765de4
Compare
|
Thank you for your contribution to Klipper. Unfortunately, a reviewer has not assigned themselves to this GitHub Pull Request. All Pull Requests are reviewed before merging, and a reviewer will need to volunteer. Further information is available at: https://www.klipper3d.org/CONTRIBUTING.html There are some steps that you can take now:
Unfortunately, if a reviewer does not assign themselves to this GitHub Pull Request then it will be automatically closed. If this happens, then it is a good idea to move further discussion to the Klipper Discourse server. Reviewers can reach out on that forum to let you know if they are interested and when they are available. Best regards, PS: I'm just an automated script, not a human being. |
|
I think threads are a more appropriate way to handle that: #7230 |
We know that os.read() will block, we assume that blocking is short enough so we can ignore that.
Generally it is true. I think there can be a situations where this assumption doesn't hold.
I think this is what happened in the log below:
It looks to me that introduce of the thread and all managment will be too combersome, to do a general solution for low probability case.
So, I purporse the fadvice
WILLNEEDhack, that will ask OS to readahead for us beforehand.Alas, it will still do synchronous readahead sometimes.
So, there is initial query to preread the whole file (size 0).
I did test the sequential and random flag.
The thing is, readahead are synchronous. So, read if it triggers the readahead, will block longer.
I can reproduce 7ms stalls where normally read takes ~20us.
Random on the other hand simply disables the readahead logic and makes all reads consistently slow (0.4ms in my case).
How I profile that
sudo strace -tT -e trace=read -p 6306 |& grep '= 8192'And this is my test gcode:
(
iostatused to see IO size andsysctl vm.drop_caches=3to reproduce something).klippy_buffer_zero.log
Testing: