Skip to content
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

fix(gc): try to not run gc when there is not enough time before the next timer #6794

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ammmze
Copy link

@ammmze ammmze commented Jan 25, 2025

This is my attempt to address Timer Too Close errors on some slower machines. Through some debugging that started with something @KevinOConnor pointed out in #6784, I observed a correlation between generation 2 collection happening at the same time as homing moves (in particular during happy hare drip/homing moves...with happy hare the user will experience many more "homing" moves than a standard non-mmu enabled printer because it "homes" filament to various sensors each time filament is swapped. I found that on my Orange Pi CM4, the generation 2 garbage collection takes between ~150-300ms depending on whether I have the shake and tune module enabled. Based on the discussion in #6784, those homing moves require low latency (<100ms) communication. So having gc that takes longer than this 100ms (which would block all other threads) is problematic. More details about my setup can be found here.

What I am doing here in his PR is tracking how long each generation garbage collection takes (with a cap of 90% of the largest free time we've seen). With this information, we can prevent doing garbage collection if there's a possibility that gc will take us past the next scheduled timer.

I am open to other ideas if you've got any. I don't think my solution is in any way bullet proof...there's still a possibility that a long running garbage collection could take too long and take us past the next timer, but I think it will be less likely.

I will acknowledge that standard klipper does do garbage collection much less frequently, but the reality is many people have extra modules like cartographer, led effects, happy hare, etc. While it would be nice if these all did their best to avoid leaving garbage for the garbage collector, the reality is that it would be a large effort and different communities have varying levels of knowledge to make this happen. So I think we should try to accommodate the best we can.

@ammmze ammmze force-pushed the ttc-gc branch 2 times, most recently from fadbbf0 to a6aba00 Compare January 25, 2025 02:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant