×
Login Register an account
Top Submissions Explore Upgoat Search Random Subverse Random Post Colorize! Site Rules Donate
6

Today for the first time in all my professional programming I actually worked on a computer science algorithms problem where I took a super imperformant O(n*n) to a O(n*logn) saving 2000ms to 15ms per frame rendered

submitted by CoronaHoax to programming 1 monthApr 1, 2025 18:35:51 ago (+6/-0)     (programming)

Crazy how rare you’re actually ever doing computer science when programming. And it’s always coveted and stolen by the ones who can’t do it lol


7 comments block


[ - ] Crackinjokes 0 points 1 monthApr 1, 2025 19:15:49 ago (+0/-0)

What's an imperformant?

[ - ] CoronaHoax [op] 0 points 4 weeksApr 2, 2025 10:10:48 ago (+0/-0)

It’s kinda like imperfect

[ - ] ClaytonBigsby313 0 points 1 monthApr 1, 2025 20:19:07 ago (+0/-0)

Check out the source code for performance mods for rimworld called 'rocketman' and 'performance fish'. they use an interesting caching method to preload the game cutting loading times to 25-50%.

[ - ] CoronaHoax [op] 0 points 1 monthApr 1, 2025 20:50:57 ago (+0/-0)

In this case I had no choice but to algorithmically make it faster. Each frame simply had to compute this unique data. It was neat to work on because normally you can solve performance issues with caching/ precomputing, etc.

[ - ] puremadness 1 point 4 weeksApr 2, 2025 03:14:34 ago (+1/-0)

I cached something today to prevent looking it up more than once.
yay science

[ - ] SithEmpire 1 point 4 weeksApr 3, 2025 04:02:21 ago (+1/-0)

Well done!

So as not to dox oneself with context, an unrelated example of how a large CPU saving happens is traversing a 3D point cloud as pairs and selecting nearby points. With a flat list it's O(n²) to check each against each other, but an initial pass to build an octree index makes nearby spatial lookup logarithmic (region size doubling/halving), giving O(n log n).

It's even better if there's a distance limit, that drops it to O(n) with a scale factor of the general cloud density.