Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: Be aware of splice

by tilly (Archbishop)
on May 03, 2004 at 18:23 UTC ( #350106=note: print w/replies, xml ) Need Help??

in reply to Be aware of splice

This example illustrates an additional point about algorithmic efficiency.

BrowserUk had initially thought that the algorithm wasn't quadratic because it didn't look quadratic in runs of 10, 100, and 1000 elements. But it did look quadratic when he tested 10_000 and 100_000.

The reason is that the quadratic piece all consists of copying pointers in C, which is very fast. You do a lot of it, so it doesn't scale, but for small sample sizes the eventual performance bottleneck is invisible. And then once the performance bottleneck becomes visible, it doesn't take long until it dominates.

Which is a basic fact about scalability. When you are dealing with small samples, you care much more about the efficiency of your individual operations. Which is relatively easy to benchmark. When you deal with large samples, you care about the scaling pattern. A very cheap operation that is at a spot which scales poorly will eventually be a bottleneck. Understanding the latter kind of problem is fairly hard for most people, and problems of this nature constantly tend to surprise people who didn't factor it in in a simple extrapolation.

(Important note: scaling bottlenecks don't just happen in code. If you spend most of your life in meetings, well you've just seen what a scaling bottleneck in an organization of humans looks like!)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://350106]
and a moth chases the moon...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (2)
As of 2018-04-23 02:50 GMT
Find Nodes?
    Voting Booth?