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
builtin: add gc_collect/0, gc_get_warn_proc/0, gc_set_warn_proc/1. Use them to turn off GC warnings by default. #20788
builtin: add gc_collect/0, gc_get_warn_proc/0, gc_set_warn_proc/1. Use them to turn off GC warnings by default. #20788
Conversation
…e them to turn off GC warnings by default.
Thanks @spytheman, this actually got me thinking... What do you think about possibly having them left on for debug builds? Or we could add an actual Unless non Anyway these just some thoughts which came to my head :) |
I like the idea of a |
I've added |
This is good to have. But the reason I was thinking it would be nice to have a flag that shows all output which could be useful for debugging is because that way it would be much easier for a developer to actually see the warning without specifically turning that on. It's unlikely they would try There may be other useful warnings hiding behind |
The previous behavior for the old libgc build, did not show those warnings. I've never missed them, and I they are about things, that I can not control, and usually do not care about => I do not want to see them, unless I am specifically debugging a GC issue.
Imho that is good.
Or, they will be overwhelmed by useless info. Consider the output of the current |
I was just writing my thoughts which where that it could be handy to see the warning since it's possible in some cases it's caused by an overlooked bug, in which case no one would ever think to try There was cases where the old version would still show warnings, perhaps not for that reason. I agree that a bunch of messages would be overwhelming. I wasn't pushing for it to be implemented, I was just mentioning what came to my head so I could see what you thought about it. |
Yes, in such cases, the new behavior of silencing such messages, will make people not aware of the warnings. On one hand, in my experience, the GC warnings were never something I cared about, or that I could do anything to solve them. On the other hand, there were often questions about how to turn them off or avoid them in the Discord server.
Yes, usually the reason for GC warnings, is programs, that allocate big chunks of memory in a loop (over 32MB). Sometimes that is a signal for a bug in the program. Sometimes it is what the program has to do. The GC does not have enough information to decide which is which, it just has a heuristic, that triggers. In the second case however, the warnings were hard to turn off. On my Linux machine, even just this, produces a warning:
I have no idea why, and I doubt, that it is indicative of a bug, that we can solve.
I think that automatic systems (like the GC), compiled in every V program, should be preferably silent, leaving all output to be what the user programmed explicitly. |
With the new prebuilt libgc.a, I get warnings when running gg programs, similar to this one:
This PR silences them by default, while also giving an API for redirecting them to a user specified callback, if needed.