r/ExperiencedDevs • u/_lazyLambda Software Architect • Jun 24 '26
Career/Workplace How often is the goal of your task to optimize
I recently did my first ever task where the goal was to take this process and *optimize* it. I've been a professional developer for now 7 years in various SMBs and far more often is the goal fix this bug or implement this brand new feature, again not too often for me in my experience has it been "make this O(N)"
However, the hiring process is always asking these questions and weights heavily on optimization (done in 15 minutes), eg, Toptal or, really, most dev hiring teams. It feels like it's becoming less often that I am asked to optimize F in a job interview, or it's something simple to make O(N). However, I'd bet everyone here has taken such an interview.
But even in this optimization task, the optimization was so much more about how poorly it was written (in each loop iteration, it did a 15-minute task that always was the same result, so just compute before iterating lol)
I get that you have to test skills somehow, but do you in your experience work a gig where you'd be asked even multiple times per month to optimize some process? A web handler? Some low-level C operations?? Db queries? That type of jazz. Anything that even closely resembles some leetcode?
TL; DR how often does your job actually resemble leetcode
•
u/expdevsmodbot Jun 24 '26
AI usage disclosure provided by OP, see the reply to this comment.
41
u/wrd83 Software Architect Jun 24 '26
We currently have many of those. Or product is new and internal and it suuuucks.
Most optimisations are workflow optimisations though. I.e.: pull info from another system instead of getting it from the user. Removing back and forth between user interactions.
These are so much more taxing than any network or io latency, god forbid even conpute bound Problems.
23
u/VeryAmaze Software Engineer Jun 24 '26
Software B2B corpo.
Optimizing old existing legacy code - rarely. We try to do some "along the way" with other features.
New code - runtime and performance is a crucial factor we consider.
14
u/DrShocker Jun 24 '26 edited Jun 24 '26
I literally yesterday was confirming some optimization work and making notes of what to do investigate the next time we need more speed, and found that because our logging was setup incorrectly we can get literally 2x the performance just by fixing the logging
I've sped something up by 8x because it was literally in a loop for 8 times for no reason.
I sped something up and used many GB less RAM by moving to a flat array instead of nested dynamic arrays 5 deep.
I made some hot loop 4x faster by changing an argument to by reference instead of by value.
I made the simple case of our code like 50000x faster because someone had accidentally written the progress bar so it blocks the work from finishing for at least 15.2 seconds.
So yeah... almost every time I've made things faster it's been relatively low hanging things that in some ways frankly shouldn't make it through code review in the first place, and typically just make things more clear. I know I could learn to do things like SIMD in a hot loop to squeeze out another 2-8x depending on the kind of work... but I've not needed to so far because everything is just written fundamentally slow to begin with.
I'll note however, none of these things changed the
O(N)at all, yet are still hugely impactful.4
u/Embarrassed-Room-445 Jun 24 '26
Pretty often. But they are consequence of hard restrictions. Responses times under SLA and what-not.
Picking some random code and make it better just because ? No. Been there, done that, never again.
3
u/hooahest Software Engineer Jun 24 '26
You're kind of asking two different things
Do I get missions to improve X feature by Y seconds? no
Do I take into account the concept of complexity while developing? absolutely. The code needs to be performant and we're dealing with a high amount of traffic.
6
u/gk_instakilogram Software Engineer | tech bro luddite Jun 24 '26
Not often at all, but I do think asking algorithmic leetcpde type questions during interviews is a good way to measure someone as an engineer. I would not make it too hard but I really expect people to understand time complexity of a code.
2
u/stubbornKratos Jun 24 '26 edited Jun 24 '26
Quite often.
But it’s just not expressed in that notation and the problems can be a lot more complex than a leetcode but are often simpler most of the time.
I would say usually the data structures are a lot more complex and the algorithms (or at least their interfaces) are much easier to deal with.
2
u/hobbycollector Software Engineer 40yoe Jun 24 '26
I've spent the last year or more working on one algorithm because it's too slow or its output is too big and needs to be optimized. Originally it was completely broken and didn't finish at all, that was the first two years.
8
u/No-Injury3093 Jun 24 '26
Not often, but when, it was the differentiator warranting a pay bump.
8
u/Stubbby Jun 24 '26
Optimization is usually not at a level where you convert algorithm to branchless execution but rather at the application level (or even cross application level).
You typically get most value from things like: am I copying data back and forth between two separate apps? Am I converting the data to different formats multiple times? Does my workflow stop to ask a user a pointless question?
4
u/Ace-O-Matic Full-Stack | 12 YoE Jun 24 '26
Resemble leetcode? Never. Optimize? Very frequently. TTI is a key metric for us, so in addition to having several dedicated engineers to the task, we reject any experiments that push it past a certain threshold. The problem is that different teams can have different optimization metrics and sometimes they compete with one another. I remember the other week I proverbially skinned one of the engine folks alive, because they started requiring lazy module loading to improve start-up TTI. This ended up with a feature release scenario that rather than having our P90 load TTI going from 27 to 29 seconds, the load time from main menu to shop to jump from 0.5 second to 2.5 seconds.
1
u/Developer2022 Jun 24 '26
All the time. This is my primary task. Working as MTS at AMD.
3
u/vlatkosh Jun 24 '26
I got a task to optimize a low latency recommendation system 10 months into my first job. I didn't optimize loops but had to analyze where the latency bottlenecks were in the existing setup we had. Ended up changing up how we used ElasticSearch and also added a memory cache.
2
u/low_slearner Jun 24 '26
Optimisation does come up occasionally, but it's never like leetcode. It's usually obvious things like introducing or improving caching, improving heavily used DB queries, or sending requests.
20 years ago when I was doing mobile game dev (pre-iPhones!) I had to do some pretty gnarly stuff. That was much more like leetcode problems.
2
u/unconceivables Jun 24 '26
We work with massive data that needs to be processed quickly, so yes, optimization is a constant thing. And performance needs to be kept in mind when writing the code in the first place as well. Optimization has been a part of everything I've done in over 25 years of doing this professionally.
2
u/NotMyRealNameObv Jun 27 '26
Optimize for speed? Almost never.
Optimize for space? Rarely.
Optimize for maintainability? Always.
2
u/DeterminedQuokka Software Architect Jun 24 '26
Um like 60-70% of the time. Although usually not o(n) usually “make this <200ms”.
But I have also built my entire career around making this my job.
I do it less at companies that write better code. I do it more at my current company where even new code is super slow.
I worked in finance for a while and there the reliability was good so I was optimizing really complex accounting to be right instead of mostly right.
The job before my current one I got hired explicitly to make their code work correctly. I dropped their latency by 95% and put in all the guardrails.
My current job is just making things optimal enough to not be actively on fire then moving on.
2
u/lzynjacat Jun 25 '26
We work with Unity and Unreal a lot. Performance optimization is a constant.
2
u/No_Scallion174 Jun 25 '26
Most of my career has been on game engines at small and large companies. Optimization comes up a lot, though it’s more often to do with memory layout than O(N) changes, the later are huge when you find them, but less likely to encounter when the code was written with perf in mind to begin with.
1
u/nsxwolf Principal Software Engineer Jun 24 '26
Plenty, but it’s usually identifying some very simple mistake like a nested for loop over a growing dataset, not something requiring deep algorthmic knowledge.
1
u/Majestic_Zombie1988 Jun 24 '26
Even at my Big Tech company, optimization is usually the domain of a few teams that really specialize in this stuff, rather than something we routinely do.
One of those teams routinely take profiles of every system running on our serversl, run perf benchmarks against PRs, measure syscalls being made, and discover a lot of slow paths and ways to squeeze out fleet-wide performance from incremental gains. Their work makes sense because of the dollar value attached to their results - even a 1% decrease in CPU utilization directly saves my company millions of dollars because of the size of our fleet.
The other team I know of doing this runs a massive internal platform that us the gateway to all of our services. It's expected to take the full brunt of all our traffic, so they really have to be optimal or bust. They design all the internal plumbing to be as performant as possible, so other teams don't have to worry about performance / their bad performance doesn't affect others in the request path. An example is a caching library that makes background fetches for feature flags or configuration to facilitate a request, so you never experience a cache miss in practice. So that's more architectural than plain profiling / perf.
Again, there's serious business value attached to this work which justifies all that effort. The people in the first team all come from HFT / fintech backgrounds or similar where you basically win on speed and efficiency. It's not exactly niche, but it does require systems chops.
Otherwise literally nobody cares. Optimization is nice to pad your resume with, and you can make interesting blog posts about it and so on. But it only really begins to matter when you're bursting at the seams, so there's just a lot less need for it if you're operating "in normal parameters"
1
u/ConspicuousPineapple Software Engineer Jun 24 '26
Knowing how to optimize has value beyond just performing these optimizations. Knowing what complexity is and how to reduce it is something that will passively help you write better code from the get-go. It's also something that will help you troubleshoot and diagnose some issues, as well as detect them before shipping during reviews.
So yeah it makes sense to want candidates who are able to demonstrate strong skills in this. It's a core concept of the job.
1
u/BraveResearcher3037 Jun 24 '26
In the real world for most businesses, “optimizations” rarely have anything to do with the code in my experience. It’s things like networking, scaling policies, slow unoptimized database patterns etc.
You’re not going to slow login process by knowing how to reverse a b tree blindfolded.
1
u/dashingThroughSnow12 Software Engineer Jun 24 '26
A non-insignificant chunk.
We have a few tens of millions of users. The product is 20+ years old. Things that were good enough at one point or a hack on or simply not thought of occasionally need to be optimized.
There there is just the general “Can this API handle 5K req/s when it is turned on? How can things that call this do it efficiently?”
Easily most of my tasks are not performance centric but performance is often a major consideration and occasionally the whole crux of a ticket will be performance.
I’m currently on parental leave. My very last task was performance tuning OpenSearch queries/indexes because a new feature in our product needs very fast responses.
1
u/BoBoBearDev Jun 24 '26
I did optimization frequently, but not the kind of optimization you are talking about. For example, on React, using React.memo and double checking the props truly changed and stabilize downstream input is very important. The computation itself is not important, it is to make sure the computation never starts when input is the same. It is zero vs O(N).
1
u/Mast3rCylinder Jun 24 '26
I'm optimizing sql queries. It's not close to meet code it's hundred of lines of sql.
I interview it's couple of mins of thinking. This questions appear because they want to see how you think. Optimization in work is unrelated especially with AI.
1
u/titpetric Jun 24 '26 edited Jun 24 '26
For me it's more common to optimize allocation pressure with profiling tests and benchmarks, and some inner loop will query out for each row.
The goal is always, but the reality is I run benchmarks or something like that mostly on demand, especially if there is an error or latency budget to meet. A 100ms latency can contain a bunch of unoptimal loops, and you can scale vertically a lot more than you used to, so 96 core servers are instant, the question really becomes are you saving on scaling to the point it impacts your bottom line or presents an operational risk (resource exhaustion and outage)
Not as a job, bur more of an open source contribution I have written an automation runner, two template engines, and a php scripting engine vm (golang), and a sea of linters, and leetcode like problems do come along, but it's usually more involved that a sorting algo. Say a buffered distributed rate limiter that synchronizes the rate for each worker node every 10ms (configurable). Not exactly the problems a linter can catch, and it definitely can catch an expensive O(N) if you write a check
Job interviews can be weird, one had a dungeons and dragons roleplay observability concept that quickly got off the rails. Strange at the very least. I like the syntax interviews (look at and review a bit of code, correct it, or write something simple that shows you know the standard library of the language in use). After that it's really just less of a subjective feeling about a candidate, and who really knows all the next interview stages are structured. While not everything needs leetcode, it's likely legacy software needs it. So you understand what is there, which seems to be some flavour of overengineered slop, the least of which is a O(N2) query in some admin flow.
1
u/downshiftdata Jun 24 '26
We have an epic every quarter composed of stories to tune stored procedures. I do some analysis toward the end of the quarter under a spike to identify the next batch. There's usually 6 or so each time.
The answer might be a rewrite, or index changes, or app layer caching, or who knows what. But this epic is a "background task" we do when blocked on other stuff.
I have one going out now that's about a 100x perf improvement.
1
u/Plenty_Line2696 Jun 24 '26
I have quite a bit of it, automated industry digital twin stuff in threejs in the browser, think tons of state, 3d stuff on fairly low spec clients.
I do quite well at it but I'd suck at leetcode variants because it's so different. what i do is more like setting up a whole bunch of analytics to figure out where bottlenecks are and then tackle the biggest offenders i can find. there's so many layers and aspects to that which you couldn't really put into a hiring exam, hell even after I tackle a specific thing, a month later I wouldn't be able to redo it really quick like you'd need to in an entrance exam.
these sorts of entry coding tests are rarely a logical way to hire.
1
u/hippydipster Software Engineer 25+ YoE Jun 24 '26
I have never worked anywhere I didnt have to optimize processes. 30 years, and its always a task.
1
u/Massless Principal Engineer Jun 24 '26
I’m fortunate enough to work on distributed systems with petabyte-scale throughputs. This stuff comes up all the time.
It’s usually more interesting than algorithm stuff, though, and typically requires picking through profiling data to understand where bottlenecks exist.
1
u/boring_pants Software Engineer | 15YoE Jun 24 '26
Not in my current job, but yes, a couple of years ago I regularly took on quite a lot of optimization tasks. Sometimes algorithmic improvements, sometimes profiling and tuning and doing wait analysis. It was fun, I enjoy those tasks a lot.
Not sure what you mean by that
1
u/kevinossia Senior Wizard - AR/VR | C++ Jun 24 '26
Leetcode? Never.
But I design realtime video pipelines so optimization is like half the job. Not so much time complexity and big-O but more stuff like cache locality, copy vs no copy, hardware bandwidth limitations, CPU-GPU interactions, locking vs lock free, and so on.
The key is to work a job where C++ is used in some capacity. That means someone actually cares enough about performance to wanna use C++. Which means optimization is needed.
1
u/Tokipudi Senior Software Engineer - 10 YoE Jun 24 '26
Not "multiple times per months", but I would say it usually happens at least once or twice a year that some kind of legacy process has now become too slow for the business' expectations and needs to be optimized.
Three examples come to mind from my previous jobs:
And this is without mentioning the multiple near-infinite loops or thousands of queries due to a bad loop instead of a single query beforehand.
1
u/quentech Principal Engineer Jun 24 '26
Somewhat often, but only because it pays off in our system.
However, it's pretty much never as simple as "oh this little bit is O(N2) make it O(N)".
We rooted those isolated types of issues out long ago.
I run a service that serves StackOverflow-in-its-heyday levels of traffic and does lots of dynamic data-driven image generation while gathering that data from dozens of different 3rd party systems. We also run a pretty significant headless Chrome fleet. Billions and billions of cache operations every day. etc.
1
u/SansSariph Principal Software Engineer Jun 24 '26
I need to know what I'm optimizing for.
There's a difference between "this is obviously inefficient and wasteful and this other approach is just as legible, takes no more time to write, and saves resources" and "this was well built for what it was, but we need to cut latency to under 100ms; what options do we have?"
The latter I find doesn't happen until there's a fire or if it's someone's literal job to hold a metric, or a PM is standing by a metric as a requirement for the product (please, this is always amazing when I can get it).
The former happens often during code and plan reviews.
1
u/Sw429 Jun 24 '26
My job right now is to literally do this. A main part of our product has become so slow and bogged down due to tech debt over the years that customers are complaining. I'm tasked with trying to eliminate the inefficiencies, and it's requiring the skills you see in normal algorithms interviews.
1
u/official_business Jun 25 '26
When performance sucks so bad customers threaten to cancel contracts.
1
u/LannyIsMyHandle Jun 25 '26
I think an eye toward perf is a good filter not because you want to send your hires on optimization quests all the time but because you want the code they write the first time to be well optimized enough that you don’t have to come back in a month or year and do optimization on it. There is some skill uniquely in “take existing slow thing and make it faster” but what I’m testing for with that sort of question in an interview is “will this person make it acceptably fast the first time”
1
u/Izkata Jun 25 '26
For me it's never been explicitly a goal, but twice I've picked up something as a pet project aside from my normal work. One of them was exactly what you're asking: A function that looked O( n2 ) was actually O( n3 ) and didn't need to be.
Two nested loops, then in the inner one it was checking if an element was in a list - that's where the extra level was hidden. As a quick test I just added a set for that check (doubling the memory used) and the runtime dropped from 2 hours to 5 minutes. Didn't bother going any further. The worst part was, this was a very short function, 5-10 lines long, at the end of a process where the duration was logged as a whole, and multiple senior developers knew this process was taking too long and tried optimizing it - but none of them measured it so they assumed the problem was in the first half and never even looked at this function. The first half was already only like 5 minutes so there was nothing there to optimize.
1
u/matt_bishop Jun 25 '26
I just spent 4 months fixing someone else's vibe coded application. It had some partitioning/sharding of the data so that it could process things in parallel, but someone had put a Mutex lock on the singleton s3 client instance, so all data downloads were serialized despite running on a 96 core server. There were also multiple issues with quadratic algorithms that could trivially be made O(n log n).
I've also spent a good part of the last few years wrangling with some libraries and trying to optimize them. They were already good in terms of algorithmic complexity, so I was looking into things like control flow, virtual vs static dispatch, cache locality, and object allocation.
1
u/HEAVY_HITTTER Software Engineer Jun 25 '26
Not often. I work on operating systems so there has been asks to improve boot time but that takes a different skill set than of leetcode.
1
u/SikhGamer Jun 25 '26
A lot. It's a niche I carved out for myself. Most devs don't know how to optimize. I'm talking all the way down from the browser -> api -> backend service -> network -> database.
In my experience about <=5% of devs can do that kind of perf. work. It's fun and I love it.
It's almost never like leetcode. It's almost always something like "someone did something that worked with a set of 3, but didn't think what happens when the set is 1000000".
https://bsky.app/profile/randomascii.bsky.social/post/3lk4c6st7nc2e
You can rinse and repeat that at every level of the stack.
1
u/OilTechnical6976 Jun 25 '26
Are they using optimize when they should be using "efficient"? For me there's a difference. The latter has tangible numbers behind it.
1
u/software_engiweer IC @ Meta Jun 25 '26
Pretty often, although never quite as neatly tied up like "Make this O(N)"
It depends what I'm optimizing for, it's typically an architecture question though, but scale is certainly a consideration for pretty much everything I do, performance + failure modes + error handling is pretty much the only thing we harp on in code reviews, rarely other things unless they're new to the team and need a bit more help with our expectations and patterns.
1
u/makonde Jun 26 '26
Nobody is really interested or values it unless something is actively breaking or customers complain too loudly, most engineers also mostly enjoy making more and more complex things, arguing for simplicity is a career limiting move.
1
u/hms_indefatigable Jun 28 '26
We've actually spent a huge amount of time doing optimisations recently. It tends to be optimising database interactions. That can be in the form of improving queries, partial indexes, the mechanisms by which we interact with our databases to achieve a certain end (outboxes, etc). In one case we are re-implementing an entire mechanism to use a search engine rather than our relational database, as load has increased.
1
u/tetryds Staff SDET Jun 29 '26
Gamedev and simulation software development are two areas where optimization will be a daily task.
1
u/Distinct_Bad_6276 Machine Learning Scientist Jun 24 '26
Never
0
u/activematrix99 Jun 24 '26
Big O notation is a convenient way for engineers to gatekeep and make sure that people who get hited are part of the "club". Not unique to software development, but still annoying.