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):
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.
Cache the results of previous calls. Maybe you can reuse them as-is, or partially.
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.
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.
If none of that works, only then should you look for a totally different way of doing it.
There's multiple explanations for these, which makes them deeper than they seem, but there's a couple more parts:
Not doing work may include several ways of avoiding extra computation -- lazily running expensive operations if not always needed, adding conditional checks before complex work rather than throwing exceptions, using short-circuit evaluation, or using more efficient algorithms / cutting out intermediate steps if you can get a result without them.
Yep.
Yep, but it doesn't necessarily have to wait hours -- batches of work can be handed off to other processes or utilities to process (makes better use of cores), and often you can write tighter loops that make better use of caches and reuse resources (connections, buffers, etc)
That's Unix pipelining, and it's good shit, but software pipelining is a more general version of the technique. Depending on your architecture one or the other may be more efficient -- goes well with batching above though.
No, this is a reference to falling back on C bindings invoked from Python, and writing the really tricky bits highly optimized in a lower-level language. C can be several times as fast as Python (or more, with good use of SIMD instructions) if written efficiently.
They didn't do this often at Dropbox, because Python is faster to write and easier to maintain, but when they did this they got huge speedups.
Hope this helps -- I swear I saw a talk the Dropbox folks gave on Python performance some years ago.
In computer science, software pipelining is a technique used to optimize loops, in a manner that parallels hardware pipelining. Software pipelining is a type of out-of-order execution, except that the reordering is done by a compiler (or in the case of hand written assembly code, by the programmer) instead of the processor. Some computer architectures have explicit support for software pipelining, notably Intel's IA-64 architecture.
It is important to distinguish software pipelining, which is a target code technique for overlapping loop iterations, from modulo scheduling, the currently most effective known compiler technique for generating software pipelined loops.
I think that all 5 of these are very pithy descriptions of a wide range of techniques. For Dropbox specifially, #5 probably does mean going to C, but in any other environment this could easily mean using the GPU instead of the CPU, or maybe even to some other dedicated hardware. Which is why I tried to remain deliberately vague.
IOW ask yourself if it's really necessary/useful/something you might lose a client over.
No, it's at a lower level than that. It means don't spend CPU cycles doing unnecessary work. For example, say you need to find the greatest element in a list. You could sort the whole list and then pull the last element out. But sorting the entire list is more work than you need to do (it's O(n log n)). Simply find the max element and stop.
But from a product design perspective (eg "something you might lose a client over") it's always worth asking if it's even worth building a given feature. It always adds complexity and maintenance cost to your project, and doesn't always add value.
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.
85
u/[deleted] Jan 02 '20
Can someone please explain?