Comment on Why do comment counts often disagree with what I see?
PeleSpirit@lemmy.world 1 year agoWhat does counter per post mean?
Also, I always thought that was because they have to “call home” to get updated and there’s time in between.
Comment on Why do comment counts often disagree with what I see?
PeleSpirit@lemmy.world 1 year agoWhat does counter per post mean?
Also, I always thought that was because they have to “call home” to get updated and there’s time in between.
athlon@lemm.ee 1 year ago
Ok, so basically, there is multiple ways one could comment count. The most obvious option is to count the actual number of comments under the post. This might be in practice slow, as you must load all comments under the post. An alternative approach is to have a count variable for post, which is increased or decreased by 1 if post is added/removed. It’s way faster to retrieve that variable, instead of getting all comments and counting the number of them. The problem starts if some anomaly happens that is not accounted for, so for example, if I request the same comment to be deleted multiple times. So that counter can be decreased more than once for the same comment. This could be fixed pretty easily:
And yeah, I thought so too, but ever since I stumbled upon this bug, I think the way the comment count is stored is through the counter variable.
PeleSpirit@lemmy.world 1 year ago
I’m sorry, I’m not really understanding since I’m not techy. Are you saying it counts how many are added or removed, not the total amount? I don’t understand the difference or why that would be easier to pull info from.
density@kbin.social 1 year ago
because when you load any page listing posts, you don't want your server to have to go and download the actual entire comment thread for every post that is listed. And then have to go and count how many there are.
Because it would be slow, especially with multiple servers involved. Every time you loaded your home page or a community the server would have to start from scratch gathering the data. It would be more accurate but it would be very hard. And not give a lot of extra value.
So it's more efficient to have a piece of data attached to the post that just reports the number of comments. Same way as there is a piece of data that contains the title, the name of the person who posted it etc. And that value is updated in some way. Apparently in a way that has not yet been perfected. :)
PeleSpirit@lemmy.world 1 year ago
I appreciate your patience, I updated my previous comment, I think I finally get what you’re saying.
athlon@lemm.ee 1 year ago
Getting the total number of all comments may be very resource heavy if there is a lot of comments.
If it’s just 5 comments, then the computer can quickly get them all from database and count how many of them are there. Now imagine if there is 50 000 comments and suddenly, you me and entire website ask “how many comments are there for this post?”
Suddenly the computer is overwhelmed by the request and you may end up crashing it due to amount of tasks it has to do.
It’s way faster if instead of all of that, the computer kept track of a number of all comments and simply adjust it when comment is added or removed. It does not have to get all the comments and count how many are there, just simply return the number and you are done.
But in the essence, you sacriface potential accuracy for speed. You may accidentally “desynchronize” the counter - if an user requests a removal of the same comment twice, and you don’t check if that comment was not removed. Or, in theory, if two separate users add or remove a comment at the same time. This is called “race condition”, which is common in multi-threaded computing.
PeleSpirit@lemmy.world 1 year ago
Okay, is it because I haven’t had my coffee yet?
First line:
Fourth paragraph:
What is the difference between the bolded parts?
baronvonj@lemmy.world 1 year ago
I had also read that editing a comment increases the comment count on a post.