Commit shaper state only when tc succeeds - #402
Conversation
set_shaper_rate updated last_shaper_rate_kbps and the delay compensations even when tc qdisc change failed, so the controller believed the new rate was installed and never retried it. Assisted-by: Claude Code
|
So that's 6 lines versus 218 with this replacement PR(!). This surely validates why @rany2 and I are so apprehensive about rapid AI-based changes to the code that has taken years to mature to the present performant state. Without careful scrutiny the code would become a mess rather quickly. So one concern I have about your approach here is that by raising an error upon a bad rate change, cake-autorate will shut itself down. Is that really what we want? Surely it'd be better to issue a warning to the user? |
Requested in review: log_msg ERROR only logs, but the label suggested otherwise; the daemon keeps running either way and retries on the next shaper update.
|
Hi, I'll make all the changes based on your feedback. I'd just ask that, if possible, you be a little more understanding instead of constantly criticizing AI—which is certainly an artifice, just like writing or the wheel, or, to stay within the realm of computer science, just like programming languages themselves, which lack consciousness; in the case of AI, it's pure logic applied in a stochastic and probabilistic manner. However, I find it really frustrating to constantly hear that AI ruins the code, after having merged countless lines of code, because the comments are too verbose or because some temporary code was left behind. Constructive criticism is fine, but complaining isn't. Thank you for your understanding. The bugs are definitely there. So are the improvements. |
|
On the technical point: |
Look @ooonea, I think @rany2 and I have actually been extremely tolerant in respect of your extensive AI-based contributions associated with code alterations, commit messages and even comments. @rany2's initial instinct was to ban you from making any contributions, and I have some sympathy for that but have been holding out because I think some of your contributions have been genuinely helpful. But there is a but here, as follows. I agree that AI can provide a useful tool. But the user must remain in the driving seat, validate everything, and bear full responsibility. I think AI is best used for checking and offering improvements; the user ought, as it were, to sit above the AI tool, sanity check everything and recognise and prevent bad suggestions. The latter has not always been happening with your contributions. Your recent pull requests: #399 and #400 were frankly a complete mess and included 218 lines and 868 lines respectively, which in the replacements #402 and #403 collapsed to 6 lines and 25 lines respectively. Events like this serve to validate our apprehensiveness. Some of your AI-based contributions or suggestions have also eaten up unnecessary time and have caused some frustration. If you are not comfortable facing criticism for your extensive use of AI then I suggest you stop contributing. Trust is earnt, and you cannot expect us not to push back when we see things like those messy pull requests or have to investigate things that end up not necessary and wasting time. |
|
And @ooonea turning to this new PR itself, I am not sure it makes sense. Now you are proposing: If the rate change fails and you want to keep the previous internal state as per the comment then surely we should set shaper_rate_kbps[${direction}] = last_shaper_rate_kbps[${direction}]? And what's the purpose of the |
|
Answering the open question for the record: |
|
@ooonea to be clear, and unless I'm mistaken, your proposal does this:
That doesn't actually achieve anything of any use because 1) the shaper rate used in the controller is still allowed to get out of sync with the actual shaper rate; and 2) return 1 is not handled. Not updating the last changed rate here does not serve any useful purpose. To illustrate:
What I think would have made sense is rather:
This would actually prevent the shaper rate as seen from the controller getting out of sync with the rate used by the shaper. |
|
You're right about the re-anchor, and my fix had that half missing. It kept Where I disagree is "doesn't achieve anything of any use": master today discards the tc exit status entirely, so For the record, the combined shape against current master, if you ever want it: if ((adjust_shaper_rate[${direction}]))
then
- tc qdisc change root dev "${interface[${direction}]}" cake bandwidth "${shaper_rate_kbps[${direction}]}Kbit" 2> /dev/null
+ if ! tc qdisc change root dev "${interface[${direction}]}" cake bandwidth "${shaper_rate_kbps[${direction}]}Kbit" 2> /dev/null
+ then
+ log_msg "WARNING" "Failed to change CAKE bandwidth on ${interface[${direction}]}."
+ # re-anchor the controller to the installed rate; keep the
+ # attempted target if no rate was ever installed (last is
+ # still 0 then, and re-anchoring to 0 would wedge here)
+ (( last_shaper_rate_kbps[${direction}] )) &&
+ (( shaper_rate_kbps[${direction}]=last_shaper_rate_kbps[${direction}] ))
+ return 1
+ fi
elseThe This was my last round here — I'll keep working on my own fork from now on. The code is GPL: take whichever half of it you find useful. Thanks for everything that did get merged. |
First, an apology for #399 and #400: those were opened by my agent tooling running unattended overnight — it was never supposed to publish anything, and the size of what it produced speaks for itself. I've corrected that on my side. The two bugs underneath are real though, so here they are as minimal, hand-checked fixes.
This one:
set_shaper_rateupdateslast_shaper_rate_kbpsand the delay compensations even whentc qdisc changefails (interface briefly gone, qdisc replaced). From that point the controller believes the new rate is installed while the kernel still runs the old one — and since the internal state advanced, the change is never retried, so autorate keeps "working" with no effect on the shaper.Fix: commit the internal state only after
tcsucceeds; on failure log an ERROR and leave the state alone so the change is retried on the next update. The monitor-only path (adjust_*_shaper_rate=0) is unchanged.Verified with a small extraction harness: on master a failed
tcstill advances the state and never retries; with the fix the state holds, one ERROR is logged, and the next update retries.bash -nand shellcheck identical to master.