6

We have existing precedence when it comes to profiling questions.

  • If you have a question about the performance of your code, then you should profile it first.
  • It should be a narrow use case which can be reproduced.
  • If you're looking to just optimize your code, you need to have done your homework before asking; just getting started and pointing at This Thing™ which may be causing slowdowns in your application isn't good enough 'round here.

To that end, I propose the following close reason.

Questions seeking help with code optimization, speed-ups or memory utilization should contain enough evidence, such as but not limited to profiling metrics, that the provided snippet is a strong culprit for poor performance. Avoid posting unproven or incomplete code, and avoid making assumptions of the code itself.

My inspiration for this: this question. This question is asking a very narrow question, but the question itself is misguided; there's no demonstrable way that the number of Strings that they're creating in that fashion is causing increased memory usage. RequestsPleas Insistence that the OP actually profile their code as opposed to guessing has gotten us nowhere.

Gold badge holders are more than equipped to have encountered these scenarios prior, and would be expected to know (more than) a thing or two about misperformant code.

38
  • 4
    @AndrewMyers: Often enough that it's not the worst thing in the world to give them some kind of lifeboat. As opposed to us burning cycles on trying to get the OP to add more details or proof that the snippet that they're posting is really the culprit, and as opposed to us dealing with answerers making flat-out guesses as to the nature of the OP's memory usage, I'd rather simply head it off. We have the tool set to do such a thing.
    – Makoto
    Commented Aug 14, 2018 at 20:35
  • 2
    @Makoto I am not convinced regarding the instant closing for gold badge holders. What makes the difference from other close reasons, the similarity to duplicates respectively? In general I agree this would be good additional close reason, and clearer as the Questions looking for debugging ... reason. Commented Aug 14, 2018 at 21:04
  • 3
    I hate those questions. Many of them, I get an immediate smell that the design of the rest of the app - that which is not posted and is probably causing 99.999% of the performance problems, is a huge pile of PHP :( Commented Aug 14, 2018 at 21:12
  • 9
    This can't go anywhere of course, you can't get them to add a close reason could only apply to 0.4% of all questions. Just write a faq that explains why such a question was closed as "too broad". Strange ask btw, you know this. Commented Aug 14, 2018 at 21:40
  • 2
    @πάνταῥεῖ: Duplicate closure is rationalized by a gold-tag badge holder having the experience of coming across or encountering that question before, and knowing where the answer is on the site. I rationalize this by a gold-tag badge holder having encountered problems of performance, and knowing how to diagnose, debug and triage them. This is definitely different and distinct from your rudimentary debugging question, because the context in which the question is being asked is different; one assumes broken code, whereas the other requires working code.
    – Makoto
    Commented Aug 14, 2018 at 21:45
  • 2
    What's wrong with VTC as unclear what you're asking: Please clarify your specific problem or add additional details to highlight exactly what you need.? You can always add a comment to clarify further your reason.
    – jpp
    Commented Aug 14, 2018 at 22:50
  • 4
    You just want to complain about questions you don't like and, for some unguessable reason, read anyway. Got it. Stop punishing yourself to get ahead, [performance] does not need your help. Answer rate is no worse than [java], very healthy voting in that community. Commented Aug 14, 2018 at 23:01
  • 3
    How is this not covered by just using a custom reason (which you can easily auto-fill with a userscript)? What percentage of to-be-closed questions do you think would use this reason? Is that percentage really sufficient to justify having this as a select-able close reason?
    – Makyen Mod
    Commented Aug 15, 2018 at 3:22
  • 9
    I seem to recall that there is a maximum number of off-topic reasons available in the close-dialog, and that SO is already at the maximum. What off-topic close reason do you propose is removed in order to replace it with this one?
    – Makyen Mod
    Commented Aug 15, 2018 at 3:24
  • 4
    If I may... That was a legitimate question. There is nothing on google that answers my question. And you want me to test it myself before asking? Then there is no need to ask. Everyone would just keep testing their code till they get the answer. All the questions like how to make get request, where to prefer ArrayList vs LinkedList, etc. All of them can be answered.... you guessed it right... by testing yourself! @Makoto
    – Faraz
    Commented Aug 15, 2018 at 12:43
  • 3
    Everyone who is in agreement that my question was not tested enough (or researched enough) before posting the question. What kind of question do you want people to ask?
    – Faraz
    Commented Aug 15, 2018 at 12:44
  • 2
    @FarazDurrani mm, I had a feeling you were really asking an "ArrayList" vs "LinkedList" question, I'm curious as to why others interpreted this as "profiling" and stuck with it even when the OP replied; it kind of struck me as a conceptual question as to how Java works (I've seen many of these sort of questions in the .NET tags). I'd recommend posting an answer to this meta post. Maybe there's an edit that can be made to make your intent clearer but as far as I can tell the only thing you did "wrong" was use the word "memory". An unfortunate situation.
    – jrh
    Commented Aug 15, 2018 at 12:52
  • 3
    @Makato: I don't exactly see what's so bad about the example question or why you think that this is a profiling issue at all. For me, this asks how string constants are handled by the compiler/runtime and if there is an optimization that handles string constants with the same content. And even if it would be a profiling question, it is definitely not unclear what op is asking, so why close-voting with that reason?
    – BDL
    Commented Aug 15, 2018 at 13:03
  • 2
    @Makoto: "there's no specification around how much memory is available to the OP, or if they're running into an active scenario in which their application is running out of memory and they've managed to trace it down to those 500 constants." It seems to me that you're trying to get enough information to know whether the asker ought to care or not. But that's ultimately irrelevant to the question itself. It doesn't matter if the OP is running out of memory and they've figured out that this is the reason why. What matters is the information they want to know. Commented Aug 15, 2018 at 15:13
  • 3
    @Makoto: What I (and I guess NicolBolas) are trying to say is: Why does it matter out of which reason op asks the question? Even if the question is asked out of plain curiosity and with no real background behind it, would it change the answer how strings constants are stored in a binary or how they are loaded? The motiviation for questions should almost never influence if they on-topic (maybe except for XY-problems where what op asks is blantly nonsense, but that isn't the case here)
    – BDL
    Commented Aug 15, 2018 at 15:32

2 Answers 2

3

I agree that we should have a close reason for questions of this sort. But I disagree that we should allow gold badge holders the power to do so unilaterally.

This kind of closure is ultimately no different from the "lacks MCVE" or "typo" forms of "off-topic". So if we don't think that gold badge holders should be able to unilaterally close those, then they shouldn't be able to unilaterally close these either. And vice-versa.

The Dupe-hammer is justified, not by expertise in skill on a topic, but by expertise in a tag on Stack Overflow. That is, you've provided enough answers on a tag that you know how that tag works, where the duplicates are, and therefore can be expected to correctly diagnose them when you see one.

That's not the case here. To deal with performance problems, you need expertise in the topics of profiling and optimization. Those are different skills from knowing where the duplicates are.

7
  • 2
    This kind of closure is ultimately no different from the "lacks MCVE" or "typo" forms of "off-topic". I think we are way too late not giving gold badge holders the ability to close questions with these reasons already.
    – Braiam
    Commented Aug 15, 2018 at 12:52
  • 2
    @Braiam Eh. I can see that both ways, to be honest. On the one hand, I frequently feel like really obviously garbage questions just don't get the eyeballs needed to clear them away. On the other hand, there are plenty of very trigger-happy close-voters, some of them gold badgers, who I wouldn't want let loose with an all-purpose closehammer, gleefully closing everything that didn't perfectly meet their personal standards. The requirement to get 4 votes of agreement is an important limitation on the power of a single person to shut down valuable Q&A; on balance, I would not want to lose it.
    – Mark Amery
    Commented Aug 15, 2018 at 13:13
  • Are you suggesting that gold-badge holders aren't experts in some capacity?
    – Makoto
    Commented Aug 15, 2018 at 15:00
  • @Makoto: I'm suggesting that holding a gold-badge is not proof of expertise in a topic. It certainly isn't proof of temperance. The only thing I would say that it "proves" is experience in the questions and answers on a particular tag on SO. Commented Aug 15, 2018 at 15:08
  • @MarkAmery well, luckily for us, the only tags with gold tag badge holders are the most popular, which also makes it more likely that there are others users that can speak out when something is not optimal.
    – Braiam
    Commented Aug 15, 2018 at 15:47
  • 1
    @Braiam: "the only tags with gold tag badge holders are the most popular" Untrue. lua is hardly popular, but it has 4 gold badge holders. glsl and shader both have one: me. And while the latter two are often combined with other tags, my point stands: in many relatively non-popular tags, it would not be difficult for a small cabal with complete close-voting power to decide what questions are and are not allowed in the tag. Commented Aug 15, 2018 at 16:09
  • "lua" "hardly popular", lets see: 14,416 questions, 20,561 answers, 6,236 answerers, only 22% unanswered. glsl and shader have respectively 2,265 and 2,464. That's enough users to put you in your place if you abuse your power. You don't need a hammer to confront a hammer.
    – Braiam
    Commented Aug 15, 2018 at 19:52
3

I'm very much against this - not just the power being granted to gold badge holders, but the close reason you propose existing at all.

It's true that misguided "which is faster" questions get posted frequently. But demanding more "complete" examples and profiler output is an awful solution.

For one thing, it's unclear to me what you think sufficiently "complete" code looks like. Presumably you don't want askers to dump the entire code of their applications. But what, then? If what I'm ultimately trying to do is decrease the memory usage of my 100000-line program, and I've got some narrow and specific question that would aid me in doing so, how much context am I meant to provide? After reading your question here, I don't have a clue what you actually want. Anyone reading your proposed close reason is going to be left in a similar state of doubt. And they're going to be justifiably pissed when they dump their entire 600 line script to satisfy your demand that they not provide "incomplete" code, only to then have their question reclosed for lacking an MCVE on the basis that the code is no longer minimal.

For another thing, an asker may not have an application to profile yet. Maybe they're asking a question because the answer will inform a design choice they have to make. That's still legit.

But most importantly, application-specific code and profiling data is typically going to be useless noise to all future readers of the question, and indeed to its answerers. If the asker is right that finding a faster way to qux the baz is the specific thing they need to do to speed up their application, then useful answers are going to have to provide a faster way to qux the baz, whether profiling information is provided or not. That's certainly the only thing that future readers arriving at the "How can I qux the baz faster?" question are going to be interested in. As far as I can tell from your question, the only reason you want to demand this information is to judge whether an asker has "done their homework" before asking (your words!) and punish them with closure if they haven't.

This is not how question closure should work. If quxing the baz performantly is something that might be useful to some people, then a question about performant baz-quxing is fine. If the particular user who asked it happened to not really need a more performant baz-quxer, that's entirely their problem. It has no bearing on whether the question is on-topic. Whether a question should remain open should depend upon its answerability and its usefulness to future readers, but it should not depend upon what some high-rep users think they can infer from it about the competence and diligence of the asker. And we should definitely not be demanding large dumps of information be added to questions that serve no purpose for anyone but close-voting gatekeepers, while not influencing the answers to the question one iota and polluting it with noise to the detriment of every single future reader. At the point that we start doing that, the closure system turns into a force that actively makes questions worse. Askers should be adding information to their questions to make them more useful; at the point that they're instead being forced to add information purely to demonstrate their moral worthiness to ask their question, something has gone badly wrong.

Let's consider your own choice of example at static variables memory footprint, which asks whether the Java compiler will create one or many instances of a string constant repeated across multiple classes (and therefore whether we pay roughly 1x the string's length or roughly nx the string's length as the memory cost of using it as a constant in n classes). It is, to my eyes, a perfectly fine question as it stands (albeit with a classically unclear title). It's interesting, it's answerable, and I can just about conceive of a context where it would be an important performance consideration, like using a code generation tool that generates large numbers of classes (the asker suggests 500) all containing the same large string constant, for use in a memory-constrained environment.

Is that the context the asker is in? Does he have another good reason for asking? Or is he an idiot? I don't know, but more importantly, I don't see why it matters.

By all means point out in a comment that this particular performance consideration simply isn't going to matter in most contexts. But why close it? What purpose does that serve?

5
  • I'll clarify my scope in the question above, but I would argue that it's fairly self-explanatory. You don't ever take on a 100,000 line program and try to find performance issues without doing some kind of triage on it. There's no reason not to expect that of askers here and now. I'm still thinking about the profiler metrics since they can actually be useful (I'm thinking of some performance issues I had with Python a long time ago in which I did use a profiler output as not noise).
    – Makoto
    Commented Aug 15, 2018 at 14:47
  • Additionally, I take strong umbrage to this being a "perfectly fine question". I can't replicate the environment that the OP is in since I don't have 500 classes readily loaded in a classpath to profile on their behalf.
    – Makoto
    Commented Aug 15, 2018 at 14:48
  • 2
    @Makoto What would you advocate to make it replicable, then? A code-generation script (written in what language?) that will produce 500 class files? Leaving that up to the answerer to create, if they want to, seems entirely fine to me. An answerer may not need to replicate the environment anyway, since they may be able to cite official documentation rather than determining the answer empirically.
    – Mark Amery
    Commented Aug 15, 2018 at 15:09
  • You're proving my point - this isn't a question we should be answering since the OP is far closer to the actual context than we are. Asking them to replicate the environment so that we can do their profiling on their behalf is a fool's errand. There are some questions which we probably shouldn't be answering, no matter the intentions on either side of the fence. I'm only trying to make that explicit.
    – Makoto
    Commented Aug 15, 2018 at 15:15
  • 2
    @Makoto I disagree entirely. The environment is replicable as it stands - the answerer just needs to write a script that creates 500 class files - and doesn't need replicating in the first place because this is a theoretical question that doesn't actually need 500 class files to test out. And all that aside, you keep talking about the OP's environment as if he actually has an existing codebase containing 500 classes with identical string constants, when you have no reason at all to think that. I strongly suspect the precise scenario presented by the asker is hypothetical.
    – Mark Amery
    Commented Aug 15, 2018 at 15:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .