Hacker News new | ask | show | jobs
by pjvsvsrtrxc 1467 days ago
Servers are expensive, too. Humans waiting on servers to process something is even more expensive. No software runs in a vacuum; someone is waiting on it somewhere.

Adding more servers doesn't generally make things faster (latency). It only raises capacity (bandwidth). It does, however, generally cost quite a bit on development. Just about the only thing worse than designing a complex system is designing a complex distributed system.

1 comments

I'm of course aware of all this.

If you don't want to take the advise of running the numbers that's up to you.

E.g. if end user latency is 10ms (and it's not voip or VR or something) then that's fast enough. Doesn't matter if it's optimizable to 10 us.

If this is code running on your million CPU farm 24/7, then yeah. But always run the numbers first.

Like I said, the vast majority of code optimization opportunities are not worth taking. Some are, but only after running the numbers.

On the flip side optimizing for human time is almost always worth it, be it end users or other developers.

But run the numbers for your company. How much does a CPU core cost per hour of it's lifetime? Your developers cost maybe $100, but maybe $1000 in opportunity cost.

Depending on what you do a server may cost you as much as one day of developer opportunity time. And then you have the server for years. (Subject to electricity)

Latency and throughput may be better solved by adding machines.

> Like I said, the vast majority of code optimization opportunities are not worth taking. Some are, but only after running the numbers.

Casey Muratori said it best: there are 3 philosophies of optimisation. You're talking about the first: actual optimisation where you measure and decide what to tackle. It's rarely used, and with good reason.

The second philosophy however is very different: it's non-pessimisation. That is, avoid having the CPU do useless work all the time. That one should be applied in a fairly systematic basis, and it's not. To apply it in practice you need to have an idea of how much time your algorithm requires. Count how many bytes are processed, how many operations are made… this should give a nice upper bound on performance. If you're within an order of magnitude of this theoretical maximum, you're probably good. Otherwise you probably missed something.

The third philosophy is fake optimisation: heuristics misapplied out of context. This one should never be used, but is more frequent than we care to admit.

I'm actually also talking about the second.

> avoid having the CPU do useless work all the time

It's not worth an engineer spending 1h a year even investigating this, if it's less than 20 CPU cores doing useless work.

The break even for putting someone full time on this is if you can expect them to save about fourty thousand CPU cores.

YMMV. Maybe you're a bank who has to have everything under physical control, and you are out of DC floor space, power budget, or physical machines.

There are other cases too. Maybe something is inherently serial, and the freshness of a pipeline's output has business value. (e.g. weather predictions for tomorrow are useless the day after tomorrow)

But if you're saying that this second way of optimizing is that things should be fast for its own sake, then you are not adding maximum value to the business, or the mission.

Performance is an instrumental goal of an effort. It's not the ultimate goal, and should not be confused for it.

In the specific case of batch processing, I hear you. Machine time is extremely cheap compared to engineer time.

Then there are interactive programs. With a human potentially waiting on it. Someone's whose time may be just as valuable as the engineer's time (morally that's 1/1, but even financially the difference is rarely more than a single order of magnitude). If you have as few as 100 users, shaving off seconds off their work is quickly worth a good chunk of your time.

Machine time is cheap, but don't forget that user's time is not.

I'm up there on the mound preaching the same thing, trust me.
You should, however, not pessimize. People make cargo-cult architecture choices that bloat their codebase, make itnless readable, and make it 100x slower.
Maybe.

Using actual numbers vetted by actual expenses in an actual company, if you can save 100 CPU cores by spending 3h a year keeping it optimized, then it is NOT worth it.

It is cheaper to burn CPU, even if you could spend one day a year making it max out one CPU core instead of 100.

It can be better for the business to cargo cult.

Not always. But you should remember that the point of the code is to solve a problem, at a low cost. Reducing complexity reduces engineer cost in the future and may also make things faster.

Put it this way: Would you hire someone at $300k doing nothing but optimizing your pipeline so that it takes one machine instead of one rack, or would you spend half that money (TCO over its lifetime) just buying a rack of machines?

If you wouldn't hire them to do it, then you shouldn't spend current engineers time doing it.

I wasn't talking about optimization! I was talking about non-pessimization, which includes not prematurely abstracting/generalizing your code.

I've seen people making poor decisions at the outset, and having code philosophies that actively make new code 100x slower without any clear gain. Over-generalization, 100 classes and subclasses, everything is an overriden virtual method, dogmatic TDD (luckily, nobody followed that.)

The dogma was to make things more complicated and illegible, 'because SOLID'.