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
Remove global variable #348
base: main
Are you sure you want to change the base?
Conversation
I suspect that this will make the code run slower, because of the extra indirections. Is there a stronger argument than "generally bad practice"? |
I don't think you'll be able to detect any difference in performance here. CPUs are crazy good at these kinds of patterns. My context is that I was working on turning this CLI into a library and needed to call it potentially many times from the same process, so having global variables was undesirable. There is one more place with static variable in disk reads that would still be a blocker for that though. I saw the opportunity to improve code a bit and decided to contribute back, but if it is not a welcome change that is fine too. |
we have measured performance degradation with smaller changes in the past. If you can demonstrate that there's no slow-down, I think this is a fine change. |
on the other hand, given bladebit, perhaps we don't care so much about a performance degradation in chiapos. |
I ran Before:
After:
I'm not sure it became faster, but shouldn't be significantly slower either. My test was not super scientific, I have a bunch of things running in background on my machine. |
We're short on time to review this, but if you fork chiapos and it works well for you, we'll consider up-streaming it. |
'This PR has been flagged as stale due to no activity for over 60 |
Generally bad practice to use global variables and easily fixable in this case