TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: Does Collapsing an HN Thread in a Popular story spike your CPU use?

11 pointsby cleverpatrickabout 2 months ago
For popular threads with a lot of comments, collapsing a top comment leads to high CPU usage and can cause browsers (I tried in Chrome and Vivaldi) to freeze up.<p>For example, this very popular thread: https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=43561253&amp;utm_term=comment<p>If you collapse the top comment, I see a huge spike in CPU and my system freezes temporarily.<p>Is it just me?

16 comments

scottlambabout 2 months ago
Collapsing the top comment (by svara) in that thread is essentially instant for me, with Chrome 134.0.6998.166 on macOS.<p>The Javascript is surprisingly readable (not minimized, not using any framework). It looks like all the comments are peers according to the DOM structure. When it collapses a comment, it loops through all the following DOM siblings until returning to the same indent level (so all the semantic descendants) and hides them one-by-one. I could see why this could be a bit slow even though it isn&#x27;t for me. I&#x27;m not really a frontend person so I don&#x27;t know why they might have chosen this structure. One could imagine if the DOM structure were set up such that the comment&#x27;s descendants were DOM descendants, it wouldn&#x27;t have to do this at all. It could just use a CSS selector that would hide elements (and thus their descendants also) if their direct parent were collapsed.
jeroenhdabout 2 months ago
I don&#x27;t see it. It&#x27;s probably an addon issue. Have you tried running the browser without addons?<p>I know, for instance, that Dark Reader seems to affect my CPU usage when mass updating DOM elements like that.<p>And I suppose it depends on your CPU, if you&#x27;re running modern browsers on a fifteen year old laptop you&#x27;re going to see CPU spikes all over the place.
JustSomeRand0about 2 months ago
I can reproduce this consistently in both Edge and Chrome. I&#x27;ve been assuming that it was a change to how Chromium redraws pages that was introduced a few months ago, but I haven&#x27;t really looked into it. I just started hitting Next instead of collapsing anything.<p>I just timed it real quick in Edge 134.0.3124.93 and collapsing svara&#x27;s top level thread hangs the browser and lags my system for 1 minute 36 seconds.
评论 #43585256 未加载
daemonologistabout 2 months ago
Not for me - CPU usage remains indistinguishable from idle and any blocking of the main thread is imperceptible. (Firefox 137 on Fedora Gnome 41)
dvhabout 2 months ago
This reminds me that one time on one Czech Linux portal when someone posted blog about crocodile infested river, there were several characters and you were supposed to decide who is more or less moral and judge their behavior in the story. The whole thread became so massive that it brought portal down and even today when you open it it loads half a minute.
评论 #43585126 未加载
krappabout 2 months ago
The javascript that hides collapsed layers probably isn&#x27;t optimized and doesn&#x27;t scale up to thousands of DOM nodes well.
DeathArrowabout 2 months ago
I use Edge on both mobile and desktop. I haven&#x27;t noticed any spike when collapsing a thread.<p>Judging from the other commeters who didn&#x27;t noticed spikes, I think there might be something related to your hardware and software combo that is causing it.
mentalgearabout 2 months ago
Funny enough just this morning, I inspected the memory usage of several of my Firefox tabs, and even though I thought HN as a quite lightweight website, I was surprised to find out that there was about 200 MB per HN tab allocated!
catgirlinspaceabout 2 months ago
I don&#x27;t see a CPU usage spike on Safari Technology Preview Release 214.
kvemkonabout 2 months ago
It takes approx 13 seconds to finish loading the page with CPU spike and firefox occupies more memory as long as the page remains opened. But then opening&#x2F;collapsing the thread is not noticeable.
pixl97about 2 months ago
Chrome and Firefox are instant for me in Windows. No CPU spike.
whatamidoingyoabout 2 months ago
It&#x27;s not just you, it happened to me a few times today. This is the first time this has happened.
areyourllySorryabout 2 months ago
it is indeed sluggish on my phone the first time i collapse, speeds up after
frou_dhabout 2 months ago
As ever, there&#x27;s no need to guess what&#x27;s happening when one has a Profiler on hand.
superkuhabout 2 months ago
Nope. I leave javascript turned off like with every other website. No CPU use issues.
评论 #43584673 未加载
anenefanabout 2 months ago
I have an old system with simple older firefox -- It can collapse the given example without even noticing ... well not perceptible to myself ... I&#x27;d call it near instantaneous, also tried repeatedly as well as going though collapsing the rest but was unable to cause a falter. I do though have a deny list of sites that provide &#x2F; contain scripts that snoop too hard as well as a couple I&#x27;m suspected set up as resident in the background where the behaviour was only corrected with quit and restart. Mind that deny list results in a few innocent sites not loading up, but I can live with that.
评论 #43584852 未加载