6 ms·
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
by TeMPOraL 6y ago
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".
- keithnz 6y agoI 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.
- vvanders 6y agoYeah 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.
- tonyhb 6y agoThe other rule is choose your data structures wisely.
- tikiman163 6y agoThe 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.
- keithnz 6y agosure, 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.
- projektfu 6y agoArchitecture 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.
- User23 6y agoThat’s not obviously absurd. If Amdahl’s law permits then Little’s law tells you whether or not it’s possible.
- projektfu 6y agoYep. As I said I’m not smart.
- hawkesnest 6y agoWow, 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!
- Aeolun 6y agoDon’t worry, we’ll use serverless! So we can support an unlimited amount of transactions per second!
- formerly_proven 6y ago