×
you are viewing a single comment's thread.

view the rest of the comments →

[–]wisam910 29 points30 points  (0 children)

Function to compute something was taking a very long time (up to a minute).

He improved its performance to near instant (less than half a second) by:

  • Using a better algorithm to reduce the time from a minute to 10 seconds

  • Simplifying the code to reduce the 10 seconds to less than half a second.

The interesting bit of the talk is the "simplifying the code".

The code was re-using a general purpose helper function for doing a certain computation, but in this case it was an over kill. Being general purpose means it does a lot of things you don't need for your specific case, and on top of that, a certain computation was being repeated all the time.

What he did first was factor out the repeated computation so he does it only one time at the beginning of the computation and then use its results.

The second thing he did is he wrote a short routine to implement the functionality that matches the specific use case.

He then went on and used SIMD to make it 8 times faster.

The original code (which was re-using other code) was doing a lot of memory allocations and other complicated things per loop iteration.

His final version is about ~20 cpu instructions per loop iteration.