Live data from Hacker News

Ask HN: How can I learn about performance optimization?

news.ycombinator.com

61–70 of 153 posts

Re: Ask HN: How can I learn about performance optimization?

#61

Measure everything and be extremely critical. Be ready to challenge common and popular held assumptions. Here is something I wrote about extreme performance in JavaScript that is discarded by most programmers because most people that program JavaScript professionally cannot really program. https://github.com/prettydiff/wisdom/blob/master/performance...

These are good performance improvements, but they clearly come at a cost. Race cars are faster than sedans, but the tires fall off and they explode without a team of engineers supporting them.

The best people I can hire can mostly use a computer. They can’t build something like this, or even build upon it. They need recipes to reuse to accomplish tasks, and the more something is custom, the harder it is to teach.

And product only cares about performance when a customer mentions it, which is almost never.

I long to spend time tuning race cars, but mostly I assemble sedans.

Re: Ask HN: How can I learn about performance optimization?

#62
One thing to keep in mind is there's three layers of optimisation:

1. The problem, 2. The algorithms, 3. Micro-optimisation.

The potential gains shrink rapidly as you descend this list. A lot of people start thinking at level 3 straight away, but this is pointless if you've left performance on the table at the higher levels. For example, no amount of clever bit twiddling will compensate for the wrong algorithm, and even the best algorithm is pointless if you're solving the wrong problem.

Re: Ask HN: How can I learn about performance optimization?

#64

Earlier quoted context omitted.

Note "faster" is not the only thing to optimize for, and it (wall clock time) is actually a bit unusual as it doesn't represent an exhaustible resource. That is, if you have a rarely used slow part of the system, that might make it seem unimportant, but not if running it uses all the disk space or drains your phone battery. Even if that doesn't happen, there are things you can optimize in the unimportant parts - you…

> Note "faster" is not the only thing to optimize for That is very true! I simply think of it first because it is often the biggest problem at my work. One of the extreme exceptions was optimising Wavetale for the Nintendo Switch, where we had to decrease memory usage from over 20GiB to below 3GiB. > is actually a bit unusual as it doesn't represent an exhaustible resource. Not in the context of game development, how…

> Not in the context of game development, however! There you typically don't care about wall time. Instead, you work towards a set frame rate meaning you have a set slice of time (usually 16.7 or 33.3 ms) to go through the entire game and render loop each time.

I was about to bring a similar example: Some of our really old daily data processing at work might need some attention and optimization in the future, because we're running out of hours in the day. And we haven't found a place we can buy more hours in the day from yet.

Re: Ask HN: How can I learn about performance optimization?

#65
post #63

1. Don't do remote calls in loops. That's it.

Really depends what you are doing. But something something loops is a good start; be weary of loops, especially nested ones, loops that call functions with other loops, loops that create variables/structures and, indeed, loops that do RPC/any type of networking.

Re: Ask HN: How can I learn about performance optimization?

#66
post #63

1. Don't do remote calls in loops. That's it.

Really depends what you are doing. But something something loops is a good start; be weary of loops, especially nested ones, loops that call functions with other loops, loops that create variables/structures and, indeed, loops that do RPC/any type of networking.

Yes, it's very reductive; anything beyond that requires more specific domain knowledge.

Re: Ask HN: How can I learn about performance optimization?

#67

It really depends on where you sit in the stack. The generally useful rule is “measure before acting”. There are some rules of thumb at every layer: If you’re getting bad scrolling in a web application on a mobile phone, something is probably getting called over and over If you’ve got an x86_64 server maxing out but the cores aren’t printing work? Zen4’s northbridge has some edge cases. If you’re trying to melt alumi…

This, measure and understand before you start messing with anything in code or infrastructure.

Lots of great resources in this thread, but as the saying goes; knowing is half the battle.

Re: Ask HN: How can I learn about performance optimization?

#68

Measure everything and be extremely critical. Be ready to challenge common and popular held assumptions. Here is something I wrote about extreme performance in JavaScript that is discarded by most programmers because most people that program JavaScript professionally cannot really program. https://github.com/prettydiff/wisdom/blob/master/performance...

> most programmers because most people that program…professionally cannot really program

FTFY

Re: Ask HN: How can I learn about performance optimization?

#69

You’re unlikely to find a good answer because it’s a very specialized skill that is mostly from experience doing it, and HN tends to self select out of that pursuit.

Anyone who cares about performance would surely see that this site does not do anything useful and eliminate it :)

Re: Ask HN: How can I learn about performance optimization?

#70
The book "Writing Efficient Programs", by Jon Bentley, is still a valuable resource. See the short subthread starting with a comment I posted here some years ago:

https://news.ycombinator.com/item?id=13407192

A few people had replied, agreeing with my opinion, and giving some more details. One of them called the book "gold".

I have also posted about the book a few other times on HN, over the years.

Those comments can be found by searching hn.algia.com for comments (not stories) matching the pattern "writing efficient programs vram22".

Post reply on HN