>I once knew
>someone who thought that a context switch was less expensive using
>shared libraries than without.

That could actually be true in some situations, for the following reason:
if program A and B have small unshared amounts of memory, but are sharing
many megabytes of libraries, potentially there are far fewer cache misses
after a context switches than there would be in the case that A and B
were each statically linked with their own copies of the many megabytes
of libraries.

However, some of this benefit is eaten by TLB misses: dynamically
linked programs tend to have much more total active virtual address
space than the corresponding statically linked programs that link only
the code they need.  And TLBs usually get flushed by context switches.
So some of the savings gained by not thrashing things in and out of the
cache is lost to thrashing things in and out of the TLBs.  TLB misses
are usually more expensive than cache misses, since a single TLB miss
can spawn many cache misses.

Reply via email to