HACKER Q&A
📣 uptownfunk

Biggest Code Speed Up?


Curious what your biggest code speed up has ever been?

Mine, obvious, but switching from element wise operations to “vectorized” operation.


  👤 monero-xmr Accepted Answer ✓
Some lessons from experience:

redis as a caching layer.

Implement high-performance code in a systems language and use bindings (i.e. ctypes in Python to call C code) for critical speedups.

Avoid lambdas and any other "serverless" code that is 10x slower and 10x more expensive than a cloud instance.

Figure out the bottleneck in a complex workflow and pre-compute as much as possible before the workflow begins, accepting stale data within defined parameters.

Manage your own memory.


👤 thfuran
Getting rid of defensive copying that ended up in a hot loop allocating a few gigabytes per second of temporary copies sped things right up. That stands out in my mind, but I know I've also fixed things that were accidentally n-squared and fell over pretty quickly in production. The other thing was actually used for some time though.

👤 pestatije
remove debug print outs