From: "Eregon (Benoit Daloze) via ruby-core" Date: 2023-03-21T13:43:11+00:00 Subject: [ruby-core:112971] [Ruby master Feature#19538] Performance warnings Issue #19538 has been updated by Eregon (Benoit Daloze). Yes, I think this would be great. TruffleRuby for instance already uses performance warnings for: * unstable interpolated regexps, i.e., an interpolated regexp for which we have seen more than N=8 different sources, so then we cannot really inline cache anymore and have to compile the regexp on the fly which is quite expensive (especially for what looks like a "literal" in source code). * some methods need caller state, when we can't find the caller node for those it means we have to walk the stack on every call to get that info, so then we warn for performance (pretty rare). In TruffleRuby those performance warnings are shown at most once per source location, that seems good to avoid too much verbosity and perf impact (of printing lots of warnings). There wasn't `Warning[]` when we added them, but I think that's a great fit. ---------------------------------------- Feature #19538: Performance warnings https://bugs.ruby-lang.org/issues/19538#change-102499 * Author: byroot (Jean Boussier) * Status: Open * Priority: Normal ---------------------------------------- Suggested by @Eregon. There are program behaviors that are supported, but that we know aren't good for performance, however it's hard for users to know about them. Now that we have warning categories, we could add a `:performance` category to allow the VM to emit warning in some situations. The category would be disabled by default, and users interested in optimizing their program could turn it on in development. ```ruby Warning[:performance] = true ``` -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/