-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Reduce "lookahead" time from 2 seconds to 1 second #7050
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
Conversation
|
cc @alfrix (klipperscreen) |
|
Hi Kevin. While I do not disagree with the change, I think we need to be careful not to increase the number of |
Agreed. Getting more test results would be good. I don't think there will be issues when using Before and after this change, the host computer needs to be able to submit moves at least as fast as the printer moves. Prior to the recent changes, a submitter could fall behind for up to about a second and still recover without causing a "print stall" event. Now with this change, a submitter may fall behind for up to about 300ms before a "print stall" is likely. Cheers, |
|
Would it be possible to add an config setting in the printer section with an default? So a user which need a higher buffer can add this value to the config? |
The timing is not something that is easily configured by an end-user. Valid values are dependent on the timing constants at the top of If we do run into issues we should be able to tweak the timing, but I think we'll need to get those test results to see if and what tweaks are needed. Cheers, |
Well, even with |
Yes - virtual_sdcard needs to be able to rapidly fill upcoming moves - enough moves to fill the lookahead buffer to the point that it flushes out enough movement to avoid a "print stall". Specifically, whenever
Hrmm. I'm not sure I understand what you are saying here. The lookahead code performs a "lazy flush" every 250ms of nominal movement ( The only time the lookahead code would not apply normal junction speeds would be if it is fully flushed due to a "print stall" event ( I'm not sure if I'm missing something or misunderstood what you were reporting. Cheers, |
Yes, this is a problematic part - so the acceleration is on the lower side, but nothing super extreme. If I run this print on the current Klipper 6118525, then it works as expected - the toolhead moves with a constant speed of 200 mm/sec, slowly going up. But if I reduce --- a/klippy/toolhead.py
+++ b/klippy/toolhead.py
@@ -190,7 +190,7 @@ class LookAheadQueue:
# Check if enough moves have been queued to reach the target flush time.
return self.junction_flush <= 0.
-BUFFER_TIME_HIGH = 2.0
+BUFFER_TIME_HIGH = 0.5
BUFFER_TIME_START = 0.250
# Main code to track events (and their timing) on the printer toolheadwhich is a bit on the extreme side currently, then I start getting print stalls on the same print. I attached both the |
|
Thanks for testing.
Yes, I think at a high-level we are "on the same page". There's a fundamental trade-off in the setting of BUFFER_TIME_HIGH - too high results in not being responsive to user requests, and too low we risk "print stall" events. Just "thinking out loud" we could change to something like
Thanks for testing. FYI, it wouldn't be valid to set Cheers, |
cb5b397 to
3529011
Compare
|
FYI, I rebased this branch and added a couple of additional minor timing tweaks (including tuning of -Kevin |
Thanks, Kevin. Then I guess it was my misunderstanding on the blocking behavior of Klipper. I was under the impression that if |
That is correct. Moves are added to the lookahead ( It used to be that steps were immediately generated and flushed from the trapq once a move was released from the lookahead queue. However, that behavior recently changed (PR #7038). Now, steps are generated from a separate timer in motion_queuing.py ( So, toolhead.py tries to keep the trapq entries 2 seconds ahead, and motion_queuing.py tries to keep the step generation 450-700ms ahead. This PR adjusts toolhead.py to keep just 1 second ahead. We could choose other times, but it wouldn't make sense for the toolhead to try to stay only 500ms ahead if the motion_queuing code is trying to stay 700ms ahead. It may seem like it's more complex to have two different timers (lookahead vs step generation). However, the previous behavior had some problems: steps weren't only generated from the toolhead (pwm_tool and manual_stepper could be active separate from normal G1 type moves); generating steps directly from lookahead queue flushes meant having to support steps generated far into the future (eg, 60+ seconds); and the close coordination between lookahead processing and step generation made the toolhead.py code very complex. So, I think the recent separation of the low-level step generation and flushing logic to the new motion_queuing.py code has benefits. It does add complexity when tweaking timing though. Maybe that helps a little, |
094ca72 to
a537e1f
Compare
Make sure each command gets an additional 100ms before flushing via the priming timer. Signed-off-by: Kevin O'Connor <[email protected]>
…ng moves Normally the toolhead code will flush the lookahead buffer every ~250ms and will briefly pause to avoid buffering too much data. That pause allows other tasks to run. Make sure to periodically yield to other tasks on each lookahead buffer flush even if a delay isn't needed. Signed-off-by: Kevin O'Connor <[email protected]>
The current code is likely to perform a lazy flush of the lookahead queue around 4 times a second. Increase that to around 6-7 times a second. This change may slightly improve the responsiveness to user requests mid-print (eg, changing extrusion ratio) and may make a "print stall" less likely in some corner cases. Signed-off-by: Kevin O'Connor <[email protected]>
During normal printing the host software would attempt to stay ahead of the micro-controller by 2 full seconds. Change that time to 1 second. This should make the software more responsive to user requests (such as pause requests). Signed-off-by: Kevin O'Connor <[email protected]>
If there are other users of the gcode mutex then pause for 50ms (instead of 100ms). Signed-off-by: Kevin O'Connor <[email protected]>
Signed-off-by: Kevin O'Connor <[email protected]>
a537e1f to
9117c09
Compare
During normal printing the host software would attempt to stay ahead of the micro-controller by 2 full seconds. Change that time to 1 second. This should make the software more responsive to user requests (such as pause requests).
This is a fairly notable change in that it should make the software feel more responsive to user input during prints - things like pausing a print, changing the extruder ratio, changing the Z offset, and similar. Now these types of mid-print commands should happen in about a second where previously it took about 2 seconds.
The recent motion queuing work makes this change more practical because the host software is more capable of rapidly generating steps (PR #7038, #7034, #7014)
@pedrolamas , @meteyou , @Sineos , @Arksine - I suspect this change may impact "load graphing tools" - any tool that previously looked at the log "buffer_time" stat. Previously that value would hover around 2 seconds, but now should hover around 1 second.
It is also possible that other tools may not expect the faster response time of mid-print commands.
-Kevin