Live data from Hacker News

Ask HN: How can I learn about performance optimization?

news.ycombinator.com

111–120 of 153 posts

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

#111
post #37

Performance optimization covers a lot of topics, it depends on what you are trying to optimize. 1. Latency vs throughput. Oftentimes they are the same, i.e. reduce the time it takes to do something. However, when you passed a certain threshold, techniques that can optimize throughput will hurt latency, so it is important to know what you are looking for. There are also low level details if you have rather extreme lat…

Adding to this great list: batch processing inputs can allow you to get more throughput at expense of latency.

This and other approaches can be found in other industries like warehousing, logging, and retail

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

#112
post #64

Earlier quoted context omitted.

> 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…

If you can run the daily batch processing in parallel, can't you have one batch start at T+0, the next one starts at T+24h, then the first one finishes at T+28h and so on?

Sadly, the resource constraints/setup prevent us from parallelizing this. And the customers of that system expect the data to be processed and available after 24 hours.

In part, it's a somewhat rewarding topic. Thinking about queries, joining a bit differently, adding another index based on new data patterns can cut hours of runtime without incurring further resource cost.

But on the other hand, it's yet another project someone dumped on the floor and we were forced to adopt it "because of the customer". And the second or third project of PD trying to "do it right" is teetering on failure once again. Cron running shell scripts held together with chicken wire and duct tape is too strong of a stack I guess.

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

#113

For several years I have worked primarily with performance optimizations in the context of video games (and previously in the context of surgical simulation). This differs subtly from optimization in certain other areas, so I figured I'd add my own perspective to this already excellent comment section. 1. First and foremost: measure early, measure often. It's been said so often and it still needs repeating. In fact,…

> The easiest way to make things go faster is to do less work. Use a more efficient algorithm, refactor code to eliminate unnecessary operations, move repeated work outside of loops. There are many flavours, but very often the biggest performance boosts are gained by simply solving the same problem through fewer instructions.

I definitely agree with this one, especially on the level of "don't make network calls in your hot loop".

But it should be noted that less efficient algorithms that access memory in a more efficient way (that is to say, get a higher percentage of cache hits when iterating the data) can beat more efficient algorithms that get more cache misses.

That's all to say, iterating over an array is very vast, and iterating through a map is not. Is the map faster if you only need to access a couple things? Well, depends on the dataset size, as well as the constant factor in your map access, and how much of an improvement your other algorithm is.

You should definitely measure that once you've made the change though.

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

#114
post #37

Performance optimization covers a lot of topics, it depends on what you are trying to optimize. 1. Latency vs throughput. Oftentimes they are the same, i.e. reduce the time it takes to do something. However, when you passed a certain threshold, techniques that can optimize throughput will hurt latency, so it is important to know what you are looking for. There are also low level details if you have rather extreme lat…

Adding to this great list: batch processing inputs can allow you to get more throughput at expense of latency.

If you make your batches small, you can get pretty much all of the benefit without adding (appreciable) latency. e.g. batch incoming web requests in 2-5 ms windows. Depending on what work is involved in a request, you might 10x your throughput and actually reduce latency if you were close to the limit of what your database could handle without batching.

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

#115
post #34

Earlier quoted context omitted.

> Latency vs throughput. Oftentimes they are the same Latency and thruput are never the same, they don't even have the same units so they can't be the same. Advice to OP. Learn how to make measurements, and you'll never make mistakes like these.

You can expand on a question without being douchey. OP is right that you can often improve both at the same time, it's just worded poorly.

Agreed. When dealing with low hanging fruit, you often improve both.

Later though… once your system is somewhat optimized, you will tend to make latency vs throughput decisions. For most people though, slight changes to latency are the cost to large increases in throughput, but that may just be my experience.

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

#116
post #76

Former HFT dev here. Know fundamentals: sources of performance issues = things that eat/waste CPU cycles, things that reach too far down the memory hierarchy. Usually the latter. E.g. L2 cache to RAM - order of magnitude slower; RAM to disk: 4+ orders of magnitude slower. Things that eat CPU: iterations, string operations. Things that waste CPU: lock contentions in multi-threaded environments, wait states. You can us…

Do you guys still buy the beefiest Intel Xeons in order to fit your main application + OS entirely within the L3 cache? There was a CppCon talk from a HFT dev about this 10 years ago.

Do you happen to know what's the CppCon talk called ?

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

#117
post #76

Former HFT dev here. Know fundamentals: sources of performance issues = things that eat/waste CPU cycles, things that reach too far down the memory hierarchy. Usually the latter. E.g. L2 cache to RAM - order of magnitude slower; RAM to disk: 4+ orders of magnitude slower. Things that eat CPU: iterations, string operations. Things that waste CPU: lock contentions in multi-threaded environments, wait states. You can us…

[dead]

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

#118
post #42
post #4

work with steve jobs, or someone like him. > One of the best, if possibly exaggerated, examples of the reality distortion field comes from Jobs's biographer Isaacson. During development of the Macintosh computer in 1984, Jobs asked Larry Kenyon, an engineer, to reduce the Mac boot time by 10 seconds. When Kenyon replied that it was not possible to reduce the time, Jobs asked him, "If it would save a person's life, co…

This feels like a bad ancedote A) kind of sounds like a toxic work environment B) this is a bad way to reason about performance without knowing more. Is this actually a bottleneck? Would the heroic effort be better spent saving minutes elsewhere where its easy to save time instead of saving seconds during boot where its hard to save time and users encounter relatively rarely? Optimizing boot might be the right call b…

I don't think anyone's ever argued that Jobs was toxic af to work with, however some engineers respond to that kind of treatment by producing best-in-class work. It's one of those trolley problem style questions, would you want this software to be twice as good at the expense of knowing ten devs were bullied like that?

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

#119
I think this thread is old enough to ask something like this, but instead of learning performance optimizatoin, is there a way to be hired to work on this? I am fascinated and I always loved when I had to optimize something (mostly code in my experience, algorithms, etc), but that's only a very small percentage of the work I do.
Post reply on HN