46

Background

When I initially encountered How can I efficiently remove elements by index from a very large list? it was titled "Remove int elements from a very large list in C#", had two close votes, and looked largely as it does now...

I have a very large list of integers (about 2 billion elements) and a list with indices (couple thousand elements) at which I need to remove elements from the first list. My current approach is to loop over all indices in the second list, passing each to the RemoveAt() method of the first list:

indices.Sort();
indices.Reverse();
for (i = 0; i < indices.Count; i++)
{
    largeList.RemoveAt(indices[i]);
}

However, it takes about 2 minutes to finish. I really need to perform this operation much faster. Is there any way of optimizing this?

I have a Intel i9X CPU with 10 cores, so maybe some way of parallel processing?

I now see that the question originally did not contain any code, so I am assuming the thrice-upvoted comment "please show your slow code!" explains those close votes.

With the question more concrete, 6 answers soon followed, and those were later incorporated into my own where I presented my solution and provided benchmark code and results for it, the other answers, and the question's implementation. I continued to improve my answer over the following days, spending (too) many hours on this (writing and testing my own solution, writing and running the benchmark for all solutions, writing and refining my answer) and related matters (i.e. fighting/filing bugs encountered along the way in the benchmark library); such are the rabbit holes Stack Overflow provides.

So, yes, I have a vested interest in this question being in a state such that people can actually read and benefit from my efforts instead of them going to waste. Now, of course, if I answer an obviously-awful question and it ends up disappearing then that's my own fault, but I don't think this is that kind of question all. Though I can't really argue with anyone who feels that question was deserving of downvotes, as I'll try to explain, I don't think it warranted any votes stronger than that.

Closure

"Needs more focus"

Finishing my work by editing the question apparently attracted the attention needed for the final close vote and, evidently, punitive downvotes for the top-voted answer and my own. The stated close reason of "This question needs to be more focused." didn't make sense, and I commented as such...

What additional focus does this question require? A specific definition of "much faster"? If the votes are keying on the "if your question has many valid answers..." part of the close description, then couldn't any question fail that criteria? How should the author know how many ways there are to make their code faster? Don't ignore the "(but no way to determine which - if any - are correct)` that follows, though; there is a way to evaluate the correctness — or, at least, merit — of an answer here: benchmarks, which is exactly what I did in my answer!

To elaborate on that, this is not the usual "What's the fastest way to do Z?" question with no code or effort that's actually asking "How do I do Z? (And make it fast, please!)"; this is really "What's a way to do Z that's faster than this?" Yes, it would have been nice if the author had made some attempt at, say, the parallel processing solution they proposed, but then they did include some attempt at solving the problem: the working code they already have that's the basis of the question.

Further, I believe "needs more focus" is sometimes used to indicate "By not attempting a solution, you haven't narrowed the realm of possible answers", but then how much scope is really required for a question about improving the performance of specific code? If one has to include not only their working baseline code but some incomplete attempt at improving it, doesn't that risk it becoming an XY question? The question changes from "What's a way to do Z that's faster than this?" to "Why isn't Q working to do Z?" with the "(faster than) this" part potentially getting lost. It seems to me that either framing has its issues if held to that standard of "focus".

The XY problem

On the subject of XY questions, I can see there being the issue that the question doesn't give any background as to why it's storing so many integers this way. This was mentioned in one of the later comments...

The question is..... why do you keep 2 billions element in memory? That's about ~8G in memory for a list of int. How about using a database for dealing with data?

It's a good point and including that kind of context in the question might have been helpful, but I don't think that's a reason for closure; Should I flag questions w/ XY problem?...

No, don't use moderator flags for this.

In general, moderator flags are for situations that cannot be handled by the community. Answerable questions are answerable, even if the answer is "You're doing it wrong."

...and What should I do when the OP asks the wrong question?...

IMHO it's questionable to ban XY problem questions from the site as off topic in general.

These can give great enlightenment for future researchers, no matter how poor the original question was asked (regarding the [MCVE] or other formal close reasons).

...seem to agree. Even if using a huge List<int> like that happens to be a poor choice for the author, it's conceivable that someone out there has a legitimate reason to do something like that and would find the question useful; just tweak the parameters — removing, say, 200,000 indices from a million-element List<Foo> — and the question still applies. If nothing else, it's an interesting question for academic purposes.

Other close reasons

It has since occurred to me that the reason in the close banner is not necessarily what ultimately got the question closed, but then I'm not sure what reason it could have been...

  • Duplicate: None was proposed. Other than the question linked in the comments, I didn't find any others that deal with removing multiple elements from a list by index (not value), let alone with the performance aspect of doing so in a huge list.

  • Off-topic: No, this is a programming question. It's asking one question. It's not seeking recommendations (other than, of course, code).

  • Needs debugging details: I will grant that the provided code is not an MVCE because it doesn't show the declaration of the two lists, but then there's nothing to debug because it's already working code. 7 answers found that code to be sufficient to understand the task at hand.

  • Needs details or clarity: I will grant that the question never explicitly mentions the List<> class, but the long-obsolete ArrayList is the only other BCL class I know of with those same methods and I think it would have said so if it used that.

    Otherwise, the framework (and, therefore, operating system), language, types, sizes, operation, and time to improve upon are all clear from the question, and the author responded to two comments seeking specific details, one of which yielded an answer (by a moderator, no less). What more information or specificity could be needed?

  • Primarily opinion-based: Did my attempt to improve the title perhaps make the question worse? Is "efficiently" considered subjective even when given an inefficient base for comparison? Otherwise, "Is there any way of optimizing this?" can be definitively answered via theory or measurements.

Whatever the reason for closure was, I couldn't do anything to fix the question because I'd already made all the improvements I could see in my edit a minute prior. Unfortunately, only one other person joined me in voting to reopen, and the question remained closed. Fine. I don't agree with it, but at least the existing answers will still be visible for future readers.

...until I noticed a couple weeks later the question was deleted, too!

Deletion

Admittedly, it's only rarely that I happen to encounter even an egregiously and unsalvageably bad question being deleted, so I am not too familiar with the process — maybe this happens all the time to other much-upvoted, much-answered questions and I've just been oblivious to it — but it's very surprising to see that one of the original close voters and two other users voted for this to happen. What's so wrong with that question that closure wasn't enough and it needed to be hidden from readers?

Bringing myself up to speed on the subject, in Privileges → Access to moderator tools I see...

When should I delete questions?

Closed questions that are of no lasting value whatsoever should be flagged and deleted.

Before voting to delete, please check whether there are any good answers; if so, then the question should be flagged for moderator attention as a potential merge candidate. We don't like to lose great answers!

How does a unique question with a +12/-3 score and 6 answers (excluding one self-deleted) with a combined score of +20/-2 even begin to qualify as "no lasting value whatsoever"?

Further, the relevant FAQ says...

What are the criteria for deletion?

For questions, a post that no longer adds anything to the site should be deleted. Basically, this includes most closed questions that cannot be improved and reopened.

I don't know how much work "no longer" is supposed to be doing in that sentence — the question no longer adds as much as it could to the site because it was closed — but I would strongly disagree that it doesn't add anything at all.

Also, I don't believe the question "cannot be improved", but then it's hard to say because, after the initial call to add code was addressed and despite the author demonstrating their responsiveness to feedback, no one took the time comment on what problem(s) remained with the question, so I can't speak to the feasibility of fixing them.

Following the quoted link is an answer to When to vote to delete question? that restates...

You delete a question when the content no longer adds anything to the site.

...and goes on to address handling each type of closure. Another answer on the same question says...

As per Jeff's post here, and answer here:

Questions which contain useful content contributed by your peers should generally be merged, not deleted.

I wish people wouldn't delete questions with good answers. You're destroying the useful contributions of your peers!

It's all about usefulness. Many questions get closed, but have useful answers that we want to preserve. Deletion votes should be based on usefulness, and that means usefulness to somebody, not just because it doesn't apply to your individual programming needs.

This Jeff person seems very wise and makes a great point about the potential for destroying quality content.

Another answer says...

If it's closed, it's fair game: vote to delete unless you can see that it has some value for the site (in which case you should probably vote to re-open).

...and yet another answer says...

It pretty much comes down to if you think the post is helpful on the site or not.

I'm seeing a trend for how to determine whether a question lives or dies. So, does a simple and clear question that hasn't been asked before with answers presenting a variety of creative approaches not have "usefulness" and "value"?

On the matter of merging questions, I did not know that's a thing. Unfortunately, it sounds like our answers could live on in that way if only the question author had made the mistake of posting an exact duplicate. Also, it's not my nature to summarily declare mine as being one of those "good", "useful" answers, but I will just say this: if mine isn't then I have no idea what one is nor what more I could possibly have done to write one. And that's not to suggest that mine was the only such answer, either.


I realize the various types of votes are subjective and, within the rules, it's up to each user to decide when and how to use theirs; what votes a post receives very much depends on who happens to encounter it. So, I really hate coming here to challenge how some users decided to use their votes, but it's just completely baffling to see the downfall of this non-terrible (at the least) question — and many person-hours of effort from myself and the other respondents nullified as a result — with no obvious (to me) reason why.

In case all the mostly-rhetorical questions in the text above get me into "too broad" territory, TL;DR here is what I'd like to know:

  • Was it appropriate to close the linked question?
  • If it was appropriate to close the linked question, was it also appropriate to delete it and, therefore, its answers?
12
  • 29
    I don't see a reason why the question should be deleted. I and another user have undeleted it.
    – Makyen Mod
    Oct 3, 2020 at 3:03
  • 12
    If you feel the question shouldn't have been deleted, why didn't you vote to undelete?
    – Makyen Mod
    Oct 3, 2020 at 3:04
  • 1
    I found it quite interesting and would only close it if a dupe was easily found. Oct 3, 2020 at 6:01
  • 13
    Wait, how did that question only need 3 delete-votes? I thought the number of delete-votes required "scales to the number of votes on the question and all its answers". What am I missing?
    – 41686d6564
    Oct 3, 2020 at 9:28
  • 47
    The energy used to delete the Question compared to the energy spent here for the resulting un-deleting is just depressing.
    – Scratte
    Oct 3, 2020 at 9:54
  • 8
    "Why do you keep 2 billions element in memory? That's about ~8G in memory for a list of int." Hmm yeah, on a Microsoft stack, that's probably an issue. Still, I cannot shake the feeling that this statement was just another variation on "640K is more memory than anyone will ever need on a computer." Oct 4, 2020 at 14:03
  • 1
    I can't help but see a common thread with Wikipedia here. There is always a faction that would prefer "neat and tidy" over "useful and informative", regardless of what the documentation says the rules are. Oct 5, 2020 at 5:45
  • Think someones going to need to lock it, already closed again and there's currently another two votes to re-open.
    – user692942
    Oct 5, 2020 at 20:55
  • Slight nitpick, but in your "The XY problem" section, it sounds like you might be conflating flags and votes for closure. The answer you linked and quoted says that XY problem questions shouldn't be flagged, but that doesn't necessarily mean they shouldn't be closed. While this is a well-written question already, I think it'd be better if that were clarified (although I don't know that it warrants a whole new edit to do so).
    – David Z
    Oct 6, 2020 at 1:02
  • @DavidZ Yes, really the part of the quoted text that I thought most relevant was "Answerable questions are answerable, even if the answer is 'You're doing it wrong.'" but I (wrongly?) opted to just quote such a short answer in its entirety. If I stripped it down to that...I'm not sure if that would be taking it out of context, or really the whole answer doesn't apply here, anyways? I did assume from that answer that neither flagging nor closing (on the XY basis) is appropriate, but, of course, it doesn't weigh in on the latter. I did not find many questions here about closing XY questions. Oct 6, 2020 at 3:42
  • 1
    @Makyen With the question securing 3 delete votes after falling short of 3 reopen votes, it did not seem likely it could then get the needed 3(?) undelete votes. (I've spent very little time in the review queues and only recently discovered the moderator tools page exists, though, so I don't know what's typical.) Also, as much as the guidelines for deletion seemed clear to me, with it getting the 3+3 votes to get to that point I couldn't rule out the "Maybe I'm just wrong/misinformed/crazy?" aspect of it; hence this question. Oct 6, 2020 at 4:58
  • @BACON Hmm, yeah it's not clear to me whether that answer is meant to make the point that XY questions merely shouldn't be flagged, or the point that they should neither be flagged nor closed. Personally, I think that ambiguity makes it not a particularly good quote to use to make your point.
    – David Z
    Oct 6, 2020 at 5:31

2 Answers 2

4

I didn't participate in any of that. But, I do have some opinions on the topic:

  1. That question is definitely too broad. One obvious piece of supporting evidence to that is that there are SIX different answers to the question. Six different people took a look at that question, and decided that it needed their contribution. Most of those answers are hours apart from each other, which means that when the person started writing their answer, there's a very high likelihood that the previously-posted answers were already in plain view, and yet they still decided the question needed more work.

    If you need six different answers, and some of those very long, to adequately address the question, the question is probably not nearly focused enough.

  2. The question also lacks evidence of any attempt to solve it, as well as any actual working example that even demonstrates the vaguely stated problem. There are three different operations in the code — sort, reverse, and remove — and the author isn't even clear about whether the "two minutes" includes all three of those operations, or if they are concerned about just the removal. The author doesn't explain what hardware they are running on, nor whether they have any reason to believe that they could significantly improve upon what they already have. Likely they could, of course, but the fact that they don't have any idea of what sort of improvement might be expected is yet more evidence that they have done exactly zero research to try to address their own question.

  3. There are certainly differences of opinion with respect to deletion. But it's my opinion that a question that's been closed for any reason other than being a duplicate has no reason to remain visible on the site, at least in the long run. Even for a duplicate, only if it's clearly a good "signpost", i.e. something that would show in searches when the actual duplicate would not.

    I do think there probably ought to be some grace period, maybe a few days, to give the author a chance to improve their question and get it reopened. But I have a hard time seeing how that incredibly weak question could ever be improved enough to provide any real value to the site. And the author of the question allowed it to languish without any improvement for over two weeks, before it eventually got deleted by the community, so even under that rule (were it implemented) the question still would've wound up deleted.

Also, frankly, while it certainly serves your own interests, I find all the voting on the question and answers discouraging, because it's almost certainly just a reflection of the "meta effect" and for sure has exactly nothing to do with the value of the question and answers relative to other questions and answers in the tag. Granted, this is as much a symptom of the broader problems of Stack Overflow — most questions and their answers in that tag, and I presume in many others, get very little love, where even a high quality question and answer might get just a few votes at most, on a good day, and often the only voting activity is from the authors of the question and single answer (*) — but it's a travesty that such a horribly useless question is getting promoted way beyond the value it actually provides to the site.


(*) And sadly, this is likely a consequence of the fact that a user's daily vote limit combines both upvotes and downvotes, combined with the fact that the site is being buried in crappy questions. There are just too many posts that need downvoting for there to be many, if any, votes left for a given user to cast upvotes on good questions and answers.

8
  • For #1, the part I struggle with most is it seems to require knowing the answer in order to ask the question. In this case there's only 4 (functional) lines of code, so not much room for tweaking, but how should the author know if the code needs just a small edit vs. a complete rewrite to be performant when that's exactly the point of the question? For #2, as I said I can't disagree with claims of little/no research (if writing the provided code counts as "research"), but is that a reason for closure vs. downvoting? Or research needs to be shown precisely to define the focus of the question? Oct 6, 2020 at 3:19
  • For #3, you say the author "allowed [the question] to languish", but then no one told them what needed fixed. I can see that being a chicken-and-egg problem — the author doesn't fix the question because they don't know anything's wrong with it, and no one points out what's wrong with it because they feel it's destined for deletion, anyways — but I suspect closure/deletion simply being more convenient than trying to improve a question (tooth-pulling as it can be, at times) may play a part, too. You make some good points about specific details missing from the question, so (cont.) Oct 6, 2020 at 3:20
  • (cont.) why is it infeasible for someone to have just commented "Does the two minutes include Sort() and Reverse()?" or "You need to specify what hardware you're using" so that could be included? You're saying a lot more information than that would be needed to make for a serviceable question? Lastly, if I could have asked about the question without linking to it (use screenshots instead to reduce traffic?) I would have; my goal wasn't to beg for undeletion (I opted not to even vote on that) or attention but to understand the thinking behind deletion, which this answer helps to do. Oct 6, 2020 at 3:20
  • @BACON: "how should the author know if the code needs just a small edit vs. a complete rewrite" -- that's not the relevant metric. What's relevant is whether the question has a clearly-stated precise goal. In any case, it will not always be the case that the author of a question knows in advance how broad it is. That doesn't keep a question from being too broad. "no one told them what needed fixed" -- sure they did. The question got closed. The closure banner tells them what they need to fix. In this case, they didn't make any attempt at all. ... Oct 6, 2020 at 3:30
  • ... "why is it infeasible for someone to have just commented" -- it's not and someone could. But as with the author of the question not knowing it's too broad, that someone didn't spend their time trying to convey what needed to be improved, does not in any way change the fact that the question needs improvement. "if I could have asked about the question without linking to it" -- that's fine...I'm not holding you accountable for the fact that the SO community can't help but to buzz around a question like this when the light's focused on it. ... Oct 6, 2020 at 3:30
  • ... But the effect remains, and it's unfortunate. It completely skews the signals that the site should be relying on to maintain quality. Oct 6, 2020 at 3:30
  • "clearly-stated precise goal." I suppose that goes back to my post-closure comment: "What additional focus does this question require? A specific definition of 'much faster'?" So, "10 seconds or less" instead of assuming "faster than 2 minutes"? Is this (from here) the banner the author sees for that close reason? To me, that and [help/closed-questions] are not an effective substitute for comments; they're so brief and unclear how they apply (here) as to leave it to guesswork for the author to fix. Oct 6, 2020 at 4:09
  • @BACON: yes, basically. "Faster" is not a suitable ask here. Otherwise, we'd all be posting our code asking for people to make it faster. This isn't a code-writing service and it's not a profiling-and-optimization service. If a person wants help making their code faster, they need to be specific. They need to explain what they've tried already; they need to explain why they think it's even possible to make the code significantly faster (which can't be done without some kind of initial investigation on their part); they need to explain what specifically they need help with. Oct 6, 2020 at 7:12
-3

I downvoted that question, and voted to close it (but not to delete), for the simple reason that it is very much a "gimme teh codez" question, and such questions tend to result in low-quality answers.

Thanks to Erik A for reminding me that I can check my profile for votes cast, I know that I downvoted that question on the same day it was posted, likely because it showed up as new on the front page of the site:

enter image description here

I voted to close it at the same time:

enter image description here

I stand by my decision to VTC. On the Stack Overflow for professional and enthusiast programmers, I would not have cast such a vote - but this is no longer that Stack Overflow, and the volume of trash that needs to be curated means that questions like these, that could end up generating great answers, instead get VTC'd and deleted instead.

A sad symptom of our Eternal September Summer of Love.

The plot twist is that I'm not sure when I VTC'd the question. The revision history says Aug 24, but I assume that was when the final vote that resulted in closure was cast. I can say it's unlikely I would've cast a close vote on a question with so many comments and answers - but considering the number of questions I see and VTC most days, it's not impossible.

Either way, I'll be more careful in future.

15
  • And VTC means what?
    – hlovdal
    Oct 5, 2020 at 7:59
  • 4
    @hlovdal Vote To Close
    – steve16351
    Oct 5, 2020 at 8:09
  • History does indeed display the final vote, in your profile under Votes -> Closure you might be able to track down when you cast the vote, but that's not searchable afaik. The initial revision was substantially worse (wall of text without any newlines or code) than the current one, I might've VTC'ed that first one too if I'd encounter it but the mystery really is the deletion after gathering lots of answers and upvotes.
    – Erik A
    Oct 5, 2020 at 9:04
  • @ErikA Thanks for reminding me of that feature - have updated the answer with my timelines.
    – Ian Kemp
    Oct 5, 2020 at 9:56
  • 11
    I disagree. In my opinion, this is not a "gimme teh codez" question and contrary to your prediction, it did not result in low-quality answers.
    – 41686d6564
    Oct 5, 2020 at 10:41
  • @41686d6564 You've made the common mistake of assuming that an exception to the rule is the rule.
    – Ian Kemp
    Oct 5, 2020 at 10:43
  • 10
    @Ian Again, I disagree. I did not base my argument on the fact that it didn't attract low-quality answers. I said that I believe it's not a low-effort question, to begin with, and it didn't even result in low-quality answers as you predicted. Why do I think it's not a low-effort question? Because it shows a straightforward problem with the OP's attempt to solve it.
    – 41686d6564
    Oct 5, 2020 at 10:45
  • @41686d6564 Then show me where effort was demonstrated.
    – Ian Kemp
    Oct 5, 2020 at 10:47
  • 9
    Using RemoveAt() is, in my opinion, an effort to solve the original problem. For a beginner, that could be the only way they could think of, but it wasn't as efficient as they were hoping. One could argue that such a question belongs on CodeReview but since it's asking about one specific problem (as opposed to asking for review on a long block of code), I think it's not (or shouldn't be) off-topic on SO.
    – 41686d6564
    Oct 5, 2020 at 10:53
  • @41686d6564 Then you did not read the last part of my answer, where I explained my rationale.
    – Ian Kemp
    Oct 5, 2020 at 10:57
  • 5
    What's the difference between "Stack Overflow for professional and enthusiast programmers" and today's Stack Overflow, such that it would cause you to cast a CV on this question or not?
    – TylerH
    Oct 5, 2020 at 17:50
  • 2
    This fundamentally doesn't answer the question of why the question deserved deletion Oct 5, 2020 at 18:09
  • @KyleDelaney No, but it does offer insight as to how the question became eligible for deletion in the first place.
    – Ian Kemp
    Oct 5, 2020 at 21:02
  • @TylerH Massively increased volume coupled with massively decreased quality today = questions that would have been okay on the "old" site needing to be closed simply as a matter of keeping our heads above water.
    – Ian Kemp
    Oct 5, 2020 at 21:04
  • Thanks for this. That's an interesting point about changing standards for quality. This answer I cited mentioned the "broken windows" theory for deletion as it pertains to Too Broad questions, and it sounds like you're saying about the same thing. However, that answer gave few examples for what constitutes a "broken window" and I didn't think it applied. @41686d6564 I think that's the complicating factor introduced by it being a performance question: does the original code constitute "research"/"effort"/"focus" or not? (I think so for "focus".) Oct 6, 2020 at 4:44

You must log in to answer this question.

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