decidim / decidim

The participatory democracy framework. A generator and multiple gems made with Ruby on Rails
https://decidim.org/
GNU Affero General Public License v3.0
1.47k stars 404 forks source link

Excessive time taken to render comments #12578

Open BigSnicker opened 8 months ago

BigSnicker commented 8 months ago

Describe the bug

When a proposal has as significant number of comments, it takes a very long time to render into the browser, sometimes minutes.

To Reproduce

Click on any proposal with a large number of comments.

Here is one on our instance, with over 150 comments: https://wedecide.green.ca/processes/create-proposals/f/457/proposals/4125#comments-for-Proposal-4125

Expected behavior

That comments would be displayed within 5-10 seconds, regardless of the number of comments.

Screenshots

No response

Stacktrace

No response

Extra data

Additional context

No response

andreslucena commented 8 months ago

Related to https://github.com/decidim/decidim/issues/7037

gordonmcdowell commented 1 week ago

I'm using Green Party of Canada's WeDecide and am experiencing an inability to load pages with many comments if I'm logged into my account. Does not matter what the client is. There are 170 comments on the policy proposal. I know that OTHER USERS do not experience this problem on the same policy proposal... it is something unique to my account.

I have sent a large number of private messages, and I suspect that is the reason why any policy proposal (not just my own) fails to load if it has many comments.

To me, watching policies gain comments and then load slower and slower until they begin to time out, it seems exponential. As if every single new comments (once there are more than 10) has a more and more significant impact on load times, until a threshold is crossed and I can no longer load the page.

Could anyone investigating this please consider that the number of private messages sent by an account might be having an impact on load times of comments? I don't see visually what impact such a relationship (me DM-ing anyone who has left a comment) could have, as there's no visual indication that I've been in a discussion with the people. But maybe the system is collecting that information so that it could be presented by the UI, even though it is never presented by the UI.

alecslupu commented 1 week ago

@gordonmcdowell is not about the number of private messages you've sent if this is a page comment. Usually, there is a number of miliseconds required for each one of the comments to load and cache. I guess that you could reload a few times the page so that the cache can be generated.

gordonmcdowell commented 1 week ago

I have reloaded the page many times. That policy proposal cited in the submission and my own (below) are the 2 with the most comments on the system...

https://wedecide.green.ca/processes/create-proposals/f/457/proposals/4213

...and I can't load comments for either, which also impedes ability to post a top-level comment.

Colin (other guy with other proposal) does NOT experience the timeout. Between me talking to Colin, and me checking with my wife's account, my own account is unique in that it is the one that times out. I've tried on many machines, many browsers, many internet connections. Reloading. Monitoring traffic.

Nothing is being delivered to the browser while the server is either SQL-ing or HTML-rendering comments.

I have not posted more comments than Colin. But I have sent more private messages than him.

Is it possible to see what the SQL looks like to generate the comment list for a policy proposal? Is it one single call? Sorry I don't have it running on my laptop to replicate, but if you can copy/paste the SQL that is used to generate the comments from any example system I'd love to take a look at it.

gordonmcdowell commented 1 week ago

Like, when I look here... https://try.decidim.org/processes/branch-cruelty/f/7/proposals/1

...I can hover over a commenter's name, and see a popup containing...

Carter Hills @jess_smitham 0 Followers 1 Follows Send private message

...so there's some consolidation of data happening for that person. I suggest that maybe Private Message data is also being consolidated, even though it is never shown? Perhaps some sort of consolidation of my-and-his private messaging?