SUMMARY: How Much of an Executable Can Be Shared?

From: Frank Wortner <frank_at_kang.bondnet.com>
Date: Wed, 22 Aug 2001 16:37:00 -0400

Thanks to Steve VanDevender and Dr. Tom Blinn for quick answers. In short,
while some numbers like sizes of text segments (which are generally read only
and shareable) are easy to determine, exact answers depend on runtime
behavior and aren't easily predictable.

Steve wrote:

The text segment and any shared libraries can be shared among multiple
instances of an executable. Shared libraries common to multiple
executables are also shared among all instances. The data (including
bss) segment is not shared (I'm not sure whether Digital UNIX does
copy-on-write data sharing, but it's safest to assume that none of the
data segment pages will be shared). Also, the data segment will grow
dynamically so to have a real sense of the overall process size you'll
have to monitor running instances of a program.

The answers, therefore, depend on the specific executable being run and
its runtime behavior. You can obtain the text and initial data segment
sizes of an executable using the "size" command. Commands like "ps" and
"top" will give some estimate of the actual size of the running
processes, but tend not to separate out text vs. data sizes.

Tom wrote:

This will sound really simplistic, and to some extent it is, but what
it comes down to is "all the private pages are unique to each process
and all the shared pages are shared". Typically, all the code pages,
whether in the program's own image or in shared libraries, are in the
"likely to be shared" category, and all the data pages including the
stack are in the "private to the process" category. File pages that
are being updated might be shared or might be private, depending. It
is possible to have shared data (e.g., with System V style shared mem
segments), and it is possible to map a file read-write in memory to
get shared persistent data, but these are special cases. But without
looking at the program's actual memory map during execution (which you
can do, I believe, looking at the "/proc" file system if you know how
to interpret the data structures), it's really hard to tell exactly
how many of a process' active pages are shared with other processes,
and it can be very dynamic during execution, so it's really hard to
come up with a simple answer.
Received on Wed Aug 22 2001 - 20:37:50 NZST

This archive was generated by hypermail 2.4.0 : Wed Nov 08 2023 - 11:53:42 NZDT