Hacker News new | past | comments | ask | show | jobs | submit login
Tell HN: Threads fast
132 points by pg on April 24, 2010 | hide | past | favorite | 26 comments
I just rewrote the code that generates the threads page to be faster. It used to be slow the first time you called it after a restart because it had to load lot of items into memory. Now items aren't loaded till the moment they're needed. This also makes it possible to show an unlimited number of threads.



Very nice. Slow threads were annoying me due to the proxy at work -- if a page took too long to respond, it would just randomly show some other page from news.yc that happened to be in the cache. (Yes, really. Now I know who else reads HN at work, and what topcolors they have chosen. ;)

This was a problem, because it seems that after I wrote a post, I immediately realized there was some error, and I needed to fix it. The page that loads after you "add commment" was also affected by the cache bug, so I couldn't get an edit link there. I would have to try "threads" a number of times, and eventually, if I was lucky, I would get the edit link. Then I could fix my post. Frustrating. (And not really HN's fault, FWIW.)

I haven't tried this through the proxy yet, but it seems massively faster from home, which should make the work proxy happier. Thanks!


i'm curious - which proxy software does that?


No idea. It's probably very expensive, though.

(The goal of our IT department is to spend the most money implementing the worst possible solutions. If it doesn't cost $5,000,000 per user per year, we're not interested. Example: I have to type 3 passwords to connect to the VPN!)


Ha! Maybe I should try bidding for their work - sounds like a nice client to have ;o)


Threads aren't really fast. The fact that you have a shared VM space allows you to avoid the cost of swapping page tables (and flushing any logically-addressed cache) but you still have to store and restore the entire architectural state, which can easily take a few hundred cycles on systems with lots of registers. Co-routines are much faster, since they allow the compiler to optimize away handling of state which it knows isn't important.

... oh wait, wrong type of threads.


Incidentally, the only usable Perl threads are implemented on top of coroutines:

http://search.cpan.org/~mlehmann/Coro-5.22/Coro.pm

Just don't read the rant about why call/cc is useless.


I had stopped using threads because I felt bad about the load I was imposing, frequently running until a timeout failure. Now it is indistinguishable from instantaneous.


>I felt bad about the load I was imposing

This is how you know you've got loyal users.


As a user of adwords I always feel bad clicking on an sponsored link in Google knowing I'm not going to buy anything.


Yet it's amazing how there is another end of the spectrum where people are hired to cost their competitors. Just the other day, I learned that apparently "Mesothelioma" is one of the more expensive AdWords that easily goes around $40!


Yes. Threads fast. Thank you.


As my mathematician partner always say, it's not unlimited, but rather a very very large amount. I've learned to stop saying unlimited or infinite around him, unless I can prove it theoretically, else he'll go into this shpeel about the finite number of atoms in the universe.


Unlimited means that the system imposes no limit on the number of threads to be displayed -- each page uses a constant amount of resources, so there is no limit to how far back in your history you can go.

That is my reading, anyway.


I agree, I'm sure that's how he meant it. However, I was just trying to be humorous, this being hacker news I thought it was applicable. Clearly nobody else appreciated it.


You're thinking of Slashdot.


Excellent, any chance the 'saved' page can get a little improvement also? At the moment it often just times out for me.


That's next on my list.


Should work reasonably well now.


It timed out the first time, then loaded fast the next time.


It works for me. Thanks.


HUGE difference for me, thanks!

Actually, everything seems faster, not just /threads


Thank you, much appreciated!


Awesome :) Looking much better from here. Thanks


Oh thank you, it was so slow, but its now zippy as can be!


Crazy lightning fast! Much appreciated.


Thank you Paul!




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: