Immutable Performance

My latest focus at work has been performance related issues. Not my performance, I'm awesome. I have a shirt that says so.

Code performance. Sheesh.

The team I'm on owns the eventing system that other teams use. I'd recognized and have finally gotten addressed performance issues on the platform itself. Which means I then have to shift to helping other teams fix performance issues in their code.

BE FUCKING IMMUTABLE

I didn't go over their code with a fine tooth comb before I had ideas of how to parallelize it.
So I bumbled and had to end the meeting early so I could put together PoC's of how to migrate the code to execute in parallel.

The biggest issue - The code was mutable. The Azure Function class had 1/2 dozen mutated variables.

I had a number of issues with this code before, but to then hit the "it can't be parallelized" blocker... fucking hell...

Mutable code is HARD to rework and refactor into a more performant system. I had to hack in a 'quick-fix' that should be good enough, but ugggggg.... it's gross.

The only painful part of this is the mutability. It's flag setting from method A, then method B checks the flags. It's lazy code. Just fucking lazy.
The whole class is chock full of lazy code... but that's how it goes.

The other sln I helped the team update to parallelization was just a "whoopsie" on my part. I forgot how to make awaited code be parallel. Dug that up and it was easy.

Just ... write immutable code. Life is easier.

Oh... Also

I still hate dependency injection.