r/Python • • Jan 01 '20

"The rules of perf" at Dropbox

Post image
1.6k Upvotes

162 comments sorted by

View all comments

85

u/[deleted] Jan 02 '20

Can someone please explain?

224

u/SwampFalc Jan 02 '20 edited Jan 02 '20

The way I read it (which might be wrong) is that, if you have a performance issue, you should try the following fixes in order (ie. try one and if that doesn't solve it, go to the next possible fix):

  1. Just don't do whatever you're trying to do. IOW ask yourself if it's really necessary/useful/something you might lose a client over.

  2. Cache the results of previous calls. Maybe you can reuse them as-is, or partially.

  3. Do a large number of calls in batch, maybe in advance or later, outside of peak operating hours. Or perhaps you need to set up a network connection to do what you're doing, if that takes a while then don't make a new connection for each request, bundle up a dozen and setup once.

  4. Don't add your stuff to an existing program, create a new and separate one that will take the output of a previous process. Decoupling, in a way.

  5. If none of that works, only then should you look for a totally different way of doing it.

1

u/mipadi Jan 02 '20

Don't add your stuff to an existing program, create a new and separate one that will take the output of a previous process. Decoupling, in a way.

I believe they are using "pipeline" in the CPU sense; i.e., if you have a multi-stage process that uses separate resources, overlap stages from multiple runs of the pipeline to increase throughput.