4 ms·
This is really an overly simplistic way to code. I urge people to think deeper up front about performance. Know your performance goals going in and code accord
by brianwawok 10y ago
This is really an overly simplistic way to code. I urge people to think deeper up front about performance.
Know your performance goals going in and code accordingly. If you require 100 micro average latency and you coded in Node.js, step 3 will be a rewrite.
Every single line of code I write, I can tell you my performance goals. If indeed it is a simple crud screen by a user, the goal may be "meh, document.ready called when viewed from 100ms browser lag within 1 second". Backend trading code would have different goals..
- karmelapple 10y agoHow do you know the speed expectations? Do you always talk concrete numbers with the stakeholders before each change you make, or just use reasonable rules of thumb you determine?
- brianwawok 10y agoDepends on the project! Asking stakeholders is good. Often then will have no idea, or say something generic like "make it fast". Try to pin them to something more concrete. "So how about adding this new feature makes X happen no more than 5% slower than it currently does"
- kasey_junk 10y agoNot before each change but before any major new initiative or refactor. Having those numbers up front is the only way to make appropriate trade offs. Having this conversation with stakeholders often educates them on the costs of performance as well. Getting 100% of responses sub 200ms is frequently orders of magnitude more expensive than getting 99% of them there, and stakeholders usually get that fast when you show them budget info.
- ansgri 10y agoReplying to the second paragraph, there often is a real value in maintaining strong upper bound for the latency, especially in distributed real-time systems (which are most of the real systems, anyway). E.g. (99% sub-200ms and 1% _unbounded_) vs (80% sub-200ms and _always_ sub-500ms) means 1% of potentially unanticipated crashes (a hell to debug and explain to customers!) vs a highly reliable system and happy customers.
- kasey_junk 10y agoFor sure, thats the definition of a real time system after all. But having conversations about what the long tails do to the "normal" path and what the costs (both in money and performance in the "normal" path) is quite simply something that you can't back into.
- ansgri 10y agoMaybe I didn't understand you correctly, but you can at least have a "return error on timeout" and process that with a predictable logic. Or maybe you do have an architecture when any individual tardy request absolutely cannot impact others. After all, I come from stream processing systems where there's only few "users" with constant streams of requests, and these users are interdependent (think control modules in a self-driving car).
- kasey_junk 10y agoWhat I'm suggesting is the decision on what you do in the case of long tail performance problems, is not something you can back into. If you are going to have timeouts with logic, that has down stream implications. If you are going to have truly independent event loops, that is a fundamental architectural decisions. None of those things match the "make it work, then make it fast". You literally have to design that into the system from jump street as it is part of the definition of "works".
- critium 10y agoMy posit was that 80% of the software an engineer will write will not require optimization and based on the responses i've been getting I should have used "rule of thumb" vs mantra. My intention was to warn the ones that read this and say, oh i gotta do all of this for every piece of software that I write, which will undoubtedly lead to overly complex code when a simple solution would have worked just as well. "Know your performance goals going in and code accordingly." I this is key sentence here and its worth repeating. Know your performance goals before your fingers touch the keyboard.
- kasey_junk 10y agoI disagree completely with your 80% number. I haven't worked on a project that had 0 performance work ever. Performance is a first class design constraint just like development time, budget & functionality, if you don't treat it as such from the beginning you are asking for trouble.
- breischl 10y agoBut different parts of a project usually have different performance goals. Typically just the important/frequently used parts need to be optimized. Infrequently used things (maybe setup, admin interface, options dialog) can usually just be "good enough." So one could say that within a project, 80% of the code isn't performance critical.
- kasey_junk 10y agoAll parts of a system have performance requirements. Some of them you might meet naively, great! But if you don't know what they are it is very hard to back into acceptable performance.
- breischl 10y agoNo kidding. Who ever said anything about not knowing what the requirements are? The point you were disagreeing with here was "80% of the software an engineer will write will not require optimization". ie, 80% of any given system hitting the performance requirements naively. So... why are you still arguing?
- BatFastard 10y agoIt depends on how familiar the engineer is with the problem space. If the engineer knows little about the problem space, then any type of optimization is not warranted until a working version is achieved. The biggest secret to writing software is "not painting yourself in the corner".
- brianwawok 10y agoIf an engineer is not familiar with the problem space, he should learn more before he writes more code.
- bryanlarsen 10y agoBut the best way to learn is often to write some code.
- sqeaky 10y agoThen the problem is an academic endeavor and hopefully not something to be sold to a customer. If it is open source, then it is likely to fall into disuse like 99.9% of open source endeavors. If it is in the 0.1% of open source projects then the community will find the effort for a rewrite, but it could be painful like python 2/3 or perl 6/7
- adrianN 10y agoHave you never written a prototype to understand your customers needs?
- sqeaky 10y agoI usually iterate. Building upon what was already built. All to often a 'prototype' becomes the finished product without the intervening iterations. If that was the plan from the start it works more smoothly.
- sqeaky 10y ago
- vinceguidry 10y ago> I urge people to think deeper up front about performance. That's part of "making it work." If you're writing backend trading code, then performance is among the first consideration.
- brianwawok 10y agoExcept I also see crud apps that take 8 seconds to load, and you can't just fix it with a cache. EVERY app has performance considerations. Literally every app. Some may be very loose.. but then spell it out, and use that to think about it.
- vinceguidry 10y agoIf you're following basic REST guidelines regarding idempotency then, yes, you can "just fix it with a cache." That's the whole point of the guideline. Updates can still take awhile, but you can fix that if you need to with a backend jobs server. Performance should always be in your mind somewhere, but it doesn't always need to be at the forefront.
- jschwartzi 10y agoUnless it's taking 8 seconds to load because your user is on 2G. Then the only way you can avoid that hit is by not making the requests in the first place.
- brianwawok 10y agoWell, or sending very compressed binary data to the user and rendering more client side, vs sending fat HTML on every click.
- andrepd 10y agoExactly. Completely ignoring performance considerations until after you got everything working right potentially means a substantial or complete rewrite of much of the code.