News for hackers. Stuff that matters.
Re:Rob Pike's Rules of Programming (1989) by TeMPOraL on Wednesday August 12, 2020 @07:54PM (#24138508)
That case you've seen speaks of the guy's inexperience and lack of understanding.

I have a problem with this rule because what I see happening is people taking it to heart and no longer thinking about what they're doing performance-wise. And then the program is working 1000x slower than it should, at no extra gain (and often a loss) of readability or safety, just because someone decided to use O(n) data structure where O(1) would do, or keeps repeating the same computation thousand times instead of ensuring it's done once.

So to your "let stuff work", I want to also add: "understand the work you're putting the computer through", and "don't do stupid things".

Re:Rob Pike's Rules of Programming (1989) by projektfu on Wednesday August 12, 2020 @09:57PM (#24139217)
Architecture is not optimization. This gets fuzzy with the decision to use caching, static generation, etc. Ideally, redis or memcached can be added when needed. It will require some changing of the app but hopefully in limited places.

This rule a la Pike is about doing things like writing assembly or manually unrolling loops in noncritical parts of code. However, in some code, almost everything is on the critical path, and that requires architecture. I’m thinking of Carmack’s single function game loop here.

I remember working on a project that claimed to want 10,000 transactions per second. “Okay”, I said, “how much can be accomplished in 100us?”

They looked at me like I was an idiot. “No, it’s going to be clustered and pipelined.”

“Ok, if you can do that maybe you have a budget of 1-5ms.”

“No, we’re going to give each transaction up to a second to get done”

I smiled and admitted that they were obviously a lot smarter than me. Oddly enough the product never saw the light of day.

Re:Rob Pike's Rules of Programming (1989) by Aeolun on Thursday August 13, 2020 @08:18AM (#24142564)
Don’t worry, we’ll use serverless! So we can support an unlimited amount of transactions per second!
Re:Rob Pike's Rules of Programming (1989) by formerly_proven on Sunday August 16, 2020 @12:38PM (#24179163)
Latency and throughput are not the same thing. A CPU can process multiple instructions per clock cycle yet instructions take longer than a clock cycle.
Re:Rob Pike's Rules of Programming (1989) by User23 on Wednesday August 12, 2020 @10:37PM (#24139413)
That’s not obviously absurd. If Amdahl’s law permits then Little’s law tells you whether or not it’s possible.
Re:Rob Pike's Rules of Programming (1989) by projektfu on Wednesday August 12, 2020 @10:47PM (#24139477)
Yep. As I said I’m not smart.
Re:Rob Pike's Rules of Programming (1989) by hawkesnest on Thursday August 13, 2020 @11:05AM (#24144051)
Wow, you are really good at this.

Let the "geniuses" figure out that to do 10k transactions/sec with processes that can handle 1 transaction/sec would take.....10k processes. Sure, doable, in specific contexts, given enough resources. But they sure as heck aren't free resources!

Re:Rob Pike's Rules of Programming (1989) by keithnz on Wednesday August 12, 2020 @08:31PM (#24138752)
I think maybe you are misreading the rule, it doesn't say don't optimize, it says when optimizing, don't guess from the code where the bottleneck is, go measure it.
Re:Rob Pike's Rules of Programming (1989) by vvanders on Wednesday August 12, 2020 @08:38PM (#24138793)
Yeah but some things like how you structure your data(which then drives CPU cache misses) aren't something you can easily adjust/tune.

Usually when you encounter one of those it's a rewrite/rearchitecture of a whole module/subsystem before you see any gains. Been there done that, not excited to repeat it again.

Re:Rob Pike's Rules of Programming (1989) by tonyhb on Wednesday August 12, 2020 @09:35PM (#24139126)
The other rule is choose your data structures wisely.
Re:Rob Pike's Rules of Programming (1989) by tikiman163 on Saturday August 15, 2020 @05:44PM (#24172694)
The number of people who don't understand when to use a list/array VS dictionary/hash table vs lookup object is too damn high. A huge amount of basic optimization is constantly at their fingertips and they nearly always choose to make a list/array and use linq to join/merge multiple relational data sets instead of optimized standard objects.
Re:Rob Pike's Rules of Programming (1989) by keithnz on Wednesday August 12, 2020 @10:32PM (#24139389)
sure, sometimes your approach is at fault, but as the rule says, sometimes it's just a surprising bottleneck. Having done a lot of embedded work, I've found that many of those can often be fixed in a straightforward manner. Sometimes, you have to change your approach though.